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
Explain what is wrong in this statement?
What are the features of c language?
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);
How do you determine a file’s attributes?
Explain what is a program flowchart and explain how does it help in writing a program?
How macro execution is faster than function ?
Do variables need to be initialized?
Why is extern used in c?
Explain what is the most efficient way to store flag values?
What is c preprocessor mean?
C program to find all possible outcomes of a dice?
What is this infamous null pointer, anyway?
Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.
how to count no of words,characters,lines in a paragraph.
How many levels of pointers can you have?