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 / venkat
void main()
{
int n,f=1,rem,x,res=0,i;
clrscr();
printf("enter a number");
scanf("%d",&n);
x=n;
for(;n>0;n=n/10)
{
rem=n%10;
f=1;
for(i=1;i<=rem;i++)
f=f*i;
res=res+f;
}
if(res==x)
printf("given number is a strong number");
else
printf("given number is not a strong number");
getch();
}
Is This Answer Correct ? | 18 Yes | 6 No |
Post New Answer View All Answers
The file stdio.h, what does it contain?
I just typed in this program, and it is acting strangely. Can you see anything wrong with it?
What is pre-emptive data structure and explain it with example?
how can use subset in c program and give more example
Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)
How can I open a file so that other programs can update it at the same time?
What does c mean in basketball?
What is the use of c language in real life?
List the difference between a "copy constructor" and a "assignment operator"?
Write a program for Overriding.
Why void main is used in c?
Without Computer networks, Computers will be half the use. Comment.
What is getch?
Why is sizeof () an operator and not a function?
Explain low-order bytes.