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 / prasad
int fact(int);
void main()
{
int sum=0,n,f,temp;
clrscr();
printf("enter the numnber u want to check:");
scanf("%d",&n);
temp=n;
while(n>o)
{
n=n%10;
f=fact(n);
sum=sum+f;
n=n/10;
}
if(sum==temp)
{
printf("given num %d is strong number:");
else
printf("given num %d is not a strong number:");
}
getch();
}
int fact(int n)
{
if(n==0)
return(1);
else
return n*fact(n-1);
}
Is This Answer Correct ? | 11 Yes | 4 No |
Post New Answer View All Answers
What oops means?
What are local static variables?
How can you increase the allowable number of simultaneously open files?
What are conditional operators in C?
Explain why c is faster than c++?
Difference between Shallow copy and Deep copy?
hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .
Can you please explain the difference between syntax vs logical error?
What is the difference between call by value and call by reference in c?
Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?
A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none
Write a program to implement queue.
What is call by reference in functions?
Explain what are binary trees?
What is the best style for code layout in c?