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 / prasad
int fact(int);
void main()
{
int sum=0,n,f,temp;
clrscr();
printf("enter the numnber u want to check:");
scanf("%d",&n);
temp=n;
while(n>o)
{
n=n%10;
f=fact(n);
sum=sum+f;
n=n/10;
}
if(sum==temp)
{
printf("given num %d is strong number:");
else
printf("given num %d is not a strong number:");
}
getch();
}
int fact(int n)
{
if(n==0)
return(1);
else
return n*fact(n-1);
}
| Is This Answer Correct ? | 11 Yes | 4 No |
Post New Answer View All Answers
how to build a exercise findig min number of e heap with list imlemented?
What is typedef example?
Explain that why C is procedural?
5 Write an Algorithm to find the maximum and minimum items in a set of ‘n’ element.
Is c call by value?
Explain how do you declare an array that will hold more than 64kb of data?
A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM
Can i use “int” data type to store the value 32768? Why?
Why is #define used?
What do mean by network ?
Write the test cases for checking a variable having value in range -10.0 to +10.0?
Is c easy to learn?
Explain how do you use a pointer to a function?
What is structure pointer in c?
Why is c fast?