write a program to check whether a given integer is a strong
number or not?
[Hint:
145=1!+4!+5!
=1+24+120
=145]

Answer Posted / venkat

void main()
{
int n,f=1,rem,x,res=0,i;
clrscr();
printf("enter a number");
scanf("%d",&n);
x=n;
for(;n>0;n=n/10)
{
rem=n%10;
f=1;
for(i=1;i<=rem;i++)
f=f*i;
res=res+f;
}
if(res==x)
printf("given number is a strong number");
else
printf("given number is not a strong number");
getch();
}

Is This Answer Correct ?    18 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?

589


What does double pointer mean in c?

584


write a program to find the given number is prime or not

3847


What are the advantages of using linked list for tree construction?

646


How can I split up a string into whitespace-separated fields?

572






Why is #define used?

791


What is the purpose of macro in C language?

664


How can I call a function with an argument list built up at run time?

642


how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?

1507


Is null equal to 0 in sql?

656


explain what is an endless loop?

612


What is difference between array and pointer in c?

541


What is the meaning of typedef struct in c?

595


Explain about the functions strcat() and strcmp()?

599


What is the purpose of ftell?

601