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
What is the scope of static variable in c?
Should I learn data structures in c or python?
the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?
Explain why can’t constant values be used to define an array’s initial size?
What is far pointer in c?
what will be maximum number of comparisons when number of elements are given?
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 ].
Explain what are multibyte characters?
What is structure pointer in c?
What is pointer & why it is used?
What is #pragma statements?
What are the c keywords?
I need a sort of an approximate strcmp routine?
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
What is auto keyword in c?