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
When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?
What does double pointer mean in c?
write a program to find the given number is prime or not
What are the advantages of using linked list for tree construction?
How can I split up a string into whitespace-separated fields?
Why is #define used?
What is the purpose of macro in C language?
How can I call a function with an argument list built up at run time?
how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?
Is null equal to 0 in sql?
explain what is an endless loop?
What is difference between array and pointer in c?
What is the meaning of typedef struct in c?
Explain about the functions strcat() and strcmp()?
What is the purpose of ftell?