Advertisement
afrinahoque

Whether the number is Armstrong number or not

Jun 22nd, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int n, rem, temp, sum=0, c;
  5.     printf("Enter the number:");
  6.     scanf("%d", &n);
  7.     temp=n;
  8.     while (temp>0)
  9.     {
  10.         rem=temp%10;
  11.         c=rem*rem*rem;
  12.         sum=sum+c;
  13.         temp=temp/10;
  14.     }
  15.     if (sum==n)
  16.         printf("It's an Armstrong Number\n");
  17.     else
  18.         printf("It's not an Armstrong Number\n");
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement