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 the 3 types of structures?
In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none
write a program for the normal snake games find in most of the mobiles.
Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?
Why is this loop always executing once?
When should I declare a function?
FILE PROGRAMMING
Explain is it better to bitshift a value than to multiply by 2?
program for reversing a selected line word by word when multiple lines are given without using strrev
What is the purpose of main() function?
In a byte, what is the maximum decimal number that you can accommodate?
Explain what are multibyte characters?
write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.
Why is c not oop?
What is static function in c?