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 / valli
int fact(int f)
{
if(f==1||f==0)
return 1;
else
return(f*fact(f-1));
}
main()
{
int n,i,j,s=0;
printf("enter the number");
scanf("%d",&n);
i=n;
while(n!=0)
{
j=n%10;
s=s+fact(j);
n=n/10;
}
if(i==s)
printf("strong number");
else
printf("not a strong number");
}
Is This Answer Correct ? | 12 Yes | 8 No |
Post New Answer View All Answers
what are bit fields? What is the use of bit fields in a structure declaration?
Explain what is the difference between functions abs() and fabs()?
how can f be used for both float and double arguments in printf? Are not they different types?
Explain high-order bytes.
Can you please explain the difference between malloc() and calloc() function?
What does double pointer mean in c?
What is variable in c example?
How can I rethow can I return a sequence of random numbers which dont repeat at all?
Describe wild pointers in c?
Do you know pointer in c?
What are keywords c?
What is array within structure?
What is table lookup in c?
Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above