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
What are the complete rules for header file searching?
Explain the array representation of a binary tree in C.
Write a program to print "hello world" without using a semicolon?
Why & is used in c?
Why does everyone say not to use gets?
What is string in c language?
What does c mean in standard form?
my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?
What is the process to generate random numbers in c programming language?
What are register variables in c?
What are the salient features of c languages?
What is the use of extern in c?
What is printf () in c?
What is the difference between malloc() and calloc() function in c language?
Explain how are 16- and 32-bit numbers stored?