Friday 30 December 2011

C program to check whether a number is a strong number



#include<stdio.h>
int fact(int);
main()
{
int n,t,r,s;
printf("Enter any number\n");
scanf("%d",&n);
t=n;
s=0;
while(n>0)
{
r=n%10;
s=s+fact(r);
n=n/10;
}
if(t==s)
printf("\n%d is a strong number",t);
else
printf("\n%d is not a strong number",t);
printf("\n");
}
int fact(int a)
{
int f,g;
f=1;
for(g=a;g>0;g--)
f=f*g;
return(f);
}



You Like It!? Then kindly share with your Friends.
Comments
0 Comments

No comments:

Post a Comment