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 / nabanita dutta
#include<stdio.h>
#main()
{
int n,sum=0,r,f=1,i=1,m;
printf("enter anumber");
scanf("%d",&n);
m=n;
while(n>0)
{
r=n%10;
for(i=1,f=1;i<=r;i++)
f=f*i;
sum=sum+f;
n=n/10;
}
if(sum==m)
printf("the given number is strong number");
else
printf("the given number is not a strong number");
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is a sequential access file?
What is data structure in c language?
What are linker error?
Explain what are bus errors, memory faults, and core dumps?
What is difference between array and pointer in c?
What is bash c?
Synonymous with pointer array a) character array b) ragged array c) multiple array d) none
How do I read the arrow keys? What about function keys?
What is a structural principle?
an expression contains relational operators, assignment operators, and arithmatic operstors. In the absence of parentheses, they will be evaluated in which of the following order a) assignment, relational, arithematic b) arithematic, relational, assignment c) relational, arithematic, assignment d) assignment, arithematic, relational
What are the application of c?
How can I find out if there are characters available for reading?
What is the purpose of void pointer?
Find duplicates in a file containing 6 digit number (like uid) in O (n) time.
What is the use of #define preprocessor in c?