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
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
What is the use of ?
int i=10; printf("%d %d %d", i, i=20, i);
Explain main function in c?
A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler
Can a void pointer point to a function?
What is difference between Structure and Unions?
Explain how many levels deep can include files be nested?
Difference between exit() and _exit() function?
p*=(++q)++*--p when p=q=1 while(q<=6)
What is malloc() function?
c program to compute AREA under integral
What are pointers really good for, anyway?
"%u" unsigned integer print the a) address of variable b) value of variable c) name of a variable d) none of the above
What is a void * in c?