Miti059

6.To cheak whether a number is armstrong number or not

Jun 23rd, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.22 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.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment