Amstrong No Code

//Amstrong No.

#include<stdio.h>
main()
{
 int n,sum=0,r,k;
 printf("enter value");
 scanf("%d",&n);
 k=n;
 while(n>0)
 {
 r=n%10;
 sum=sum+r*r*r;
 n=n/10; 
 }
     if(sum==k)
     {
     printf("it is an armstrong no");
     }
 else
      printf("it is not an armstrong no");
}

No comments:

Post a Comment