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
Can we declare variable anywhere in c?
what do u mean by Direct access files? then can u explain about Direct Access Files?
What is the difference between break and continue?
Write a program of prime number using recursion.
Explain the binary height balanced tree?
Explain the difference between call by value and call by reference in c language?
What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
What are the different types of endless loops?
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
Why & is used in scanf in c?
#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); }
What is the use of header?
What is structure padding and packing in c?
What is #include stdio h?
Describe the steps to insert data into a singly linked list.