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 / mathew varghese

#include<stdio.h>
void main()
{
int x,y,z,sum=0,h=1,t;
int factorial (int g, int k);
printf("enter a value to check whether it is strong
number...\n");
scanf("%d",&x);
printf("\nthe entered value is:::: %d \n ",x);
t=x;
while(x>0)
{
y=x%10;
x=x/10;
z=factorial(y,h);
sum=sum+z;
}
if(sum==t)
{
printf("\n %d is a strong no:\n",t);
}
else
{
printf("\n %d is not a strong no:\n",t);
}
}
int factorial (int g, int k)
{
while(g>=1)
{
k=k*g;
g=g-1;
}
return k;
}

Is This Answer Correct ?    44 Yes 24 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is wrong in this statement?

635


What are the features of c language?

622


a=10;b= 5;c=3;d=3; if(a printf(%d %d %d %d a,b,c,d) else printf("%d %d %d %d a,b,c,d);

646


How do you determine a file’s attributes?

603


Explain what is a program flowchart and explain how does it help in writing a program?

650






How macro execution is faster than function ?

669


Do variables need to be initialized?

623


Why is extern used in c?

613


Explain what is the most efficient way to store flag values?

701


What is c preprocessor mean?

796


C program to find all possible outcomes of a dice?

1856


What is this infamous null pointer, anyway?

612


Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.

3127


how to count no of words,characters,lines in a paragraph.

3908


How many levels of pointers can you have?

706