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
What are variables and it what way is it different from constants?
How can a string be converted to a number?
Why main function is special give two reasons?
Explain how can I manipulate strings of multibyte characters?
What are the 4 types of functions?
which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above
What is void pointers in c?
number of times a digit is present in a number
how can I convert a string to a number?
What is the size of empty structure in c?
How main function is called in c?
What does void main () mean?
What is logical error?
What is a pointer value and address in c?
write a c program to find the sum of five entered numbers using an array named number