Code.GeekInterview.com
 
Code Samples C++
 

Armstrong Number


Code ResourceAuthor: Priya  

Difficulty Level:

Published: 16th Sep 2007   Read: 27875 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. Priya49234
2. chowsys23035
3. bipin_vaylu18072
4. rachittyagi14311
5. raghu.mohindru12156
6. Subashini10965
7. vimal.fire10639
8. venki_madesh9398
9. vipin gupta9030
10. Mehedi Shams Rony8720

Active Coders

Refined Tags