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
Do you know the use of 'auto' keyword?
Explain the use of 'auto' keyword in c programming?
What is the use of sizeof () in c?
How can you access memory located at a certain address?
Explain union.
What is context in c?
The performance of an operation in several steps with each step using the output of the preceding step a) recursion b) search c) call by value d) call by reference
What is console in c language?
When was c language developed?
What is #include stdio h?
the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above
What do the functions atoi(), itoa() and gcvt() do?
What is a global variable in c?
Is main is a keyword in c?
What is variable and explain rules to declare variable in c?