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

Armstrong Number


Code ResourceAuthor: Priya  

Difficulty Level:

Published: 16th Sep 2007   Read: 7074 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. Priya11452
2. bipin_vaylu5081
3. chowsys5007
4. raghu.mohindru4429
5. venki_madesh3286
6. vimal.fire2998
7. Subashini2641
8. prabha2484
9. vipin gupta2073
10. Mehedi Shams Rony1830

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