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

Armstrong Number


Code ResourceAuthor: Priya  

Difficulty Level:

Published: 16th Sep 2007   Read: 6799 times  

Filed in: C++
Add Comment


 


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 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. Priya10971
2. bipin_vaylu4911
3. chowsys4868
4. raghu.mohindru4325
5. venki_madesh3221
6. vimal.fire2914
7. Subashini2442
8. prabha2407
9. vipin gupta2016
10. Mehedi Shams Rony1802

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