Advertisement
RIFATKHAN1

check whether a number is Armstrong number or not.

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