Code.GeekInterview.com
 
Code Samples C++
 

Armstrong Number


Code ResourceAuthor: Priya  

Difficulty Level:

Published: 16th Sep 2007   Read: 28788 times  

Filed in: C++
Add Comment


 

 

Sponsored Links


 

 

To check whether a number is armstrong number or not.

 


Sample Code
  1.  
  2. /* To check whether a number is armstrong number or not */
  3. #include
  4. #include
  5. #include
  6. void main()
  7. {
  8. int i,n,r,f,sum=0;
  9. clrscr();
  10. printf("Enter a no.n");
  11. scanf("%d",&n);
  12. f=n;
  13. while (n>0)
  14. {
  15. r=n%10;
  16. n=n/10;
  17. sum+=pow(r,3);
  18. }
  19. if (sum==f)
  20. printf("%d is an armstrong no.n",f);
  21. else
  22. printf("%d is not an armstrong no.n",f);
  23. getch();
  24. }
Copyright GeekInterview.com


Next Article: Adam Number


 

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. Priya50712
2. chowsys23743
3. bipin_vaylu18399
4. rachittyagi15147
5. raghu.mohindru12453
6. Subashini11189
7. vimal.fire10898
8. venki_madesh10114
9. vipin gupta9277
10. Mehedi Shams Rony9071

Active Coders

# Coder NameCodes
1. chowsys4
2. Priya2
3. rachittyagi1
4. jbode1
5. vipin gupta1
6. Mehedi Shams Rony1
7. cddhu1
8. Subashini1
9. venki_madesh1
10. prabha1

Refined Tags