Code.GeekInterview.com
  I am new, Sign me up!
 
Code Samples C++
 

Adam Number


Code ResourceAuthor: Priya  

Difficulty Level:

Published: 16th Sep 2007   Read: 4386 times  

Filed in: C++
Add Comment


 


To check whether a number is adam number or not

 


Sample Code
  1.  
  2. /* To check whether a number is adam number or not */
  3. #include
  4. #include
  5. void main()
  6. {
  7. int i,n,n1,n2,ns,r,rev=0,nr=0,nrs;
  8. clrscr();
  9. printf("Enter a no.n");
  10. scanf("%d",&n);
  11. ns=n;
  12. n1=n*n;
  13. n2=n1;
  14. while(n2>0)
  15. {
  16. r=n2%10;
  17. n2=n2/10;
  18. rev=rev*10+r;
  19. }
  20. while(ns>0)
  21. {
  22. r=ns%10;
  23. ns=ns/10;
  24. nr=nr*10+r;
  25. }
  26. nrs=nr*nr;
  27. if (rev==nrs)
  28. printf("%d is an adam no.n",n);
  29. else
  30. printf("%d is not an adam no.n",n);
  31. getch();
  32. }
  33. }
Copyright GeekInterview.com


Next Article: Swaping Two Numbers


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Comment


Members Please Login

Name:  Email: (Optional. Used for Notification)

Title:
 
Comment:
Validation Code: <=>  (Enter this code in text box)





Popular Coders

# Coder NameHits
1. Priya11478
2. bipin_vaylu5095
3. chowsys5028
4. raghu.mohindru4436
5. venki_madesh3293
6. vimal.fire3011
7. Subashini2659
8. prabha2486
9. vipin gupta2080
10. Mehedi Shams Rony1834

Active Coders

Refined Tags

 

Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact  

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape