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 is structure packing in c?
What 'lex' does?
Write a factorial program using C.
Is c is a high level language?
What is zero based addressing?
Explain pointers in c programming?
What are the types of data files?
Write a program to print fibonacci series using recursion?
What is the use of getch ()?
Can two or more operators such as and be combined in a single line of program code?
How do we print only part of a string in c?
What is #define in c?
What is property type c?
What is difference between structure and union in c programming?
What do you mean by c what are the main characteristics of c language?