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


Please Help Members By Posting Answers For Below Questions

What's the total generic pointer type?

606


What are header files? What are their uses?

630


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

633


How can I find out the size of a file, prior to reading it in?

610


What are data types in c language?

578






Why is c called "mother" language?

849


What math functions are available for integers? For floating point?

614


Explain what header files do I need in order to define the standard library functions I use?

642


What are the two types of structure?

567


What do you mean by a local block?

621


Explain how can you avoid including a header more than once?

591


What does int main () mean?

539


What is sizeof c?

598


When would you use a pointer to a function?

580


What does typedef struct mean?

646