Breaking News

Program to check the number is strong number or not in C

#include
#include
main()
{
int x,n;
printf("Enter a number :");
scanf("%d",&n);
x=strong(n);
if(x==n)
printf("Strong");
else
printf("Not strong");
}
int strong(int n)
{
int s=0,r,f;
while(n>0)
{
r=n%10;
f=fact(r);
s=s+f;
n=n/10;
}
return s;
}
int fact(int n)
{
int f=1;
while(n>0)
{
f=f*n;
n--;
}
return f;
}

No comments