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


Please Help Members By Posting Answers For Below Questions

Can we declare variable anywhere in c?

534


what do u mean by Direct access files? then can u explain about Direct Access Files?

1640


What is the difference between break and continue?

604


Write a program of prime number using recursion.

615


Explain the binary height balanced tree?

722






Explain the difference between call by value and call by reference in c language?

645


What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

624


What are the different types of endless loops?

622


How to write a code for implementing my own printf() and scanf().... Please hep me in this... I need a guidance... Can you give an coding for c... Please also explain about the header files used other than #include...

4902


Why & is used in scanf in c?

623


#include main() { enum _tag{ left=10, right, front=100, back}; printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back); }

712


What is the use of header?

620


What is structure padding and packing in c?

619


What is #include stdio h?

681


Describe the steps to insert data into a singly linked list.

620