Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #include <conio.h>
  4.  
  5. void main()
  6. {
  7. int n,copy,sum,x,j;
  8.  
  9. for(j=1;j<=500;j=j+1)
  10. {
  11. sum=0;
  12. n=j;
  13. copy=n;
  14.  
  15. for(;n>0;)
  16. {
  17. x=n%10;
  18. n=n/10;
  19. sum=sum+(x*x*x);
  20. }
  21.  
  22. if(sum==copy)
  23. {printf("%d is an Armstrong number\n",sum);}
  24.  
  25. }
  26. getch();
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement