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 / giridhar

#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;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 ?    27 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the scope of static variable in c?

539


Should I learn data structures in c or python?

589


the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?

569


Explain why can’t constant values be used to define an array’s initial size?

863


What is far pointer in c?

816






what will be maximum number of comparisons when number of elements are given?

1413


Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].

649


Explain what are multibyte characters?

631


What is structure pointer in c?

577


What is pointer & why it is used?

609


What is #pragma statements?

595


What are the c keywords?

754


I need a sort of an approximate strcmp routine?

665


main use of recursive function a) processing speed high b) reduce program length/reduce repeated statements c) if you do not, use iterative methods like, for, while or do-while d) all the above

619


What is auto keyword in c?

792