Code.GeekInterview.com
 
Code Samples C++
 

Adam Number


Code ResourceAuthor: Priya  

Difficulty Level:

Published: 16th Sep 2007   Read: 15761 times  

Filed in: C++
Add Comment


 

 

Sponsored Links


 

 

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 Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    



Popular Coders

# Coder NameHits
1. Priya38091
2. chowsys15722
3. bipin_vaylu14142
4. raghu.mohindru9071
5. Subashini7733
6. rachittyagi7489
7. vimal.fire7392
8. venki_madesh6527
9. prabha6512
10. vipin gupta6321

Active Coders

Refined Tags