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
How reliable are floating-point comparisons?
What is the difference between array and pointer?
What is malloc calloc and realloc in c?
Tell me can the size of an array be declared at runtime?
What is the heap in c?
write a program to find out prime number using sieve case?
Explain what is the difference between a string and an array?
Why c is called a mid level programming language?
Is null a keyword in c?
Difference between goto, long jmp() and setjmp()?
Why is extern used in c?
Why doesnt the call scanf work?
Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?
How do you declare a variable that will hold string values?
Explain what is the benefit of using #define to declare a constant?