Code.GeekInterview.com
 
Code Samples C++
 

Armstrong Number


Code ResourceAuthor: Priya  

Difficulty Level:

Published: 16th Sep 2007   Read: 27841 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. Priya49164
2. chowsys22959
3. bipin_vaylu18049
4. rachittyagi14263
5. raghu.mohindru12139
6. Subashini10936
7. vimal.fire10607
8. venki_madesh9358
9. vipin gupta9010
10. Mehedi Shams Rony8687

Active Coders

Refined Tags