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
How can I get random integers in a certain range?
When was c language developed?
How can you find the exact size of a data type in c?
what is a function method?give example?
What is pointer in c?
What is function prototype?
How would you rename a function in C?
What are the advantages of union?
What is the meaning of typedef struct in c?
Input is "rama loves rajesh and rajesh Loves rama also and rajesh wear gloves and bloves" To print output is count the numbers of times repeted the word love without case sensitive.
How to declare pointer variables?
Describe dynamic data structure in c programming language?
What do you understand by friend-functions? How are they used?
How can I convert a number to a string?
What is modeling?