Advertisement
Istanvir389

Armstrong

Aug 22nd, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4. int n,r, remainder, result = 0;
  5.  
  6. printf("Enter a three digit integer: ");
  7. scanf("%d", &n);
  8.  
  9. r=n;
  10.  
  11. while (r!= 0)
  12. {
  13. remainder = r%10;
  14. result += remainder*remainder*remainder;
  15. r /= 10;
  16. }
  17.  
  18. if(result == n)
  19. printf("%d is an Armstrong number.",n);
  20. else
  21. printf("%d is not an Armstrong number.",n);
  22.  
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement