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 is array in c with example?
Can a void pointer point to a function?
What is else if ladder?
Write a program to swap two numbers without using third variable?
Is r written in c?
Explain can static variables be declared in a header file?
When we use void main and int main?
List some of the dynamic data structures in C?
Define recursion in c.
Differentiate Source Codes from Object Codes
How are portions of a program disabled in demo versions?
What are the ways to a null pointer can use in c programming language?
How would you rename a function in C?
What is the use of sizeof () in c?
What is default value of global variable in c?