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


Please Help Members By Posting Answers For Below Questions

What oops means?

585


What are local static variables?

620


How can you increase the allowable number of simultaneously open files?

598


What are conditional operators in C?

628


Explain why c is faster than c++?

576






Difference between Shallow copy and Deep copy?

1573


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 .

1904


Can you please explain the difference between syntax vs logical error?

698


What is the difference between call by value and call by reference in c?

621


Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?

600


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

734


Write a program to implement queue.

667


What is call by reference in functions?

571


Explain what are binary trees?

614


What is the best style for code layout in c?

633