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 / dally
#include<stdio.h>
int main()
{
int n = 145;
int i,sum=0,temp;
temp = n;
while(n>1)
{
n=n%10;
sum = sum+fact(n);
printf("%d",sum);
}
if(temp == sum)
printf("Given no is STRONG number\n");
}
int fact(int a)
{
int i=1,fact=1;
fact = i*fact(--i);
return fact;
}
Is This Answer Correct ? | 18 Yes | 17 No |
Post New Answer View All Answers
What is static and auto variables in c?
can we change the default calling convention in c if yes than how.........?
Explain how can a program be made to print the name of a source file where an error occurs?
Can the sizeof operator be used to tell the size of an array passed to a function?
Explain how do you search data in a data file using random access method?
In a header file whether functions are declared or defined?
What is non linear data structure in c?
What is the translation phases used in c language?
What is the purpose of the preprocessor directive error?
What are the types of pointers in c?
How do we print only part of a string in c?
can anyone suggest some site name..where i can get some good data structure puzzles???
What is static volatile in c?
Write a program to display all the prime nos from 1 to 1000000, your code should not take time more than a minute to display all the nos.
What are multibyte characters?