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 / dally
#include<stdio.h>
int main()
{
int n = 145;
int i,sum=0,temp;
temp = n;
while(n>1)
{
n=n%10;
sum = sum+fact(n);
printf("%d",sum);
}
if(temp == sum)
printf("Given no is STRONG number\n");
}
int fact(int a)
{
int i=1,fact=1;
fact = i*fact(--i);
return fact;
}
| Is This Answer Correct ? | 18 Yes | 17 No |
Post New Answer View All Answers
Why we use void main in c?
Can you assign a different address to an array tag?
why do some people write if(0 == x) instead of if(x == 0)?
What is the difference between union and structure in c?
What is spark map function?
What is use of bit field?
Why c is procedure oriented?
How many parameters should a function have?
State the difference between realloc and free.
Are global variables static in c?
What does the c preprocessor do?
What are enums in c?
In c language can we compile a program without main() function?
What is the purpose of sprintf() function?
Why is c still so popular?