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
What's the total generic pointer type?
What are header files? What are their uses?
the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset
How can I find out the size of a file, prior to reading it in?
What are data types in c language?
Why is c called "mother" language?
What math functions are available for integers? For floating point?
Explain what header files do I need in order to define the standard library functions I use?
What are the two types of structure?
What do you mean by a local block?
Explain how can you avoid including a header more than once?
What does int main () mean?
What is sizeof c?
When would you use a pointer to a function?
What does typedef struct mean?