Mim527

6.Armstrong number

Jun 21st, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. #include<stdio.h>
  2. main()
  3. {
  4.     int n,a,sum=0,r;
  5.     scanf("%d",&n);
  6.     while(n>0)
  7.     {
  8.         r=n%10;
  9.         a=r*r*r;
  10.         sum=sum+a;
  11.         n=n/10;
  12.     }
  13.     if(n==sum)
  14.     printf("Armstrong number");
  15.     else
  16.         printf("not Armstrong number ");
  17.         return 0;
  18.  
  19. }
Add Comment
Please, Sign In to add comment