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 / venkat
void main()
{
int n,f=1,rem,x,res=0,i;
clrscr();
printf("enter a number");
scanf("%d",&n);
x=n;
for(;n>0;n=n/10)
{
rem=n%10;
f=1;
for(i=1;i<=rem;i++)
f=f*i;
res=res+f;
}
if(res==x)
printf("given number is a strong number");
else
printf("given number is not a strong number");
getch();
}
| Is This Answer Correct ? | 18 Yes | 6 No |
Post New Answer View All Answers
What is the scope of local variable in c?
#include
C language questions for civil engineering
Explain the ternary tree?
What is meant by 'bit masking'?
How can you determine the size of an allocated portion of memory?
Write a code to generate divisors of an integer?
Hi can anyone tell what is a start up code?
What are structures and unions? State differencves between them.
Explain output of printf("Hello World"-'A'+'B'); ?
Explain how can a program be made to print the line number where an error occurs?
What are the advantages of using macro in c language?
How do I determine whether a character is numeric, alphabetic, and so on?
What are the uses of a pointer?
What is a union?