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


Please Help Members By Posting Answers For Below Questions

What is static and auto variables in c?

567


can we change the default calling convention in c if yes than how.........?

2035


Explain how can a program be made to print the name of a source file where an error occurs?

691


Can the sizeof operator be used to tell the size of an array passed to a function?

620


Explain how do you search data in a data file using random access method?

698






In a header file whether functions are declared or defined?

629


What is non linear data structure in c?

577


What is the translation phases used in c language?

636


What is the purpose of the preprocessor directive error?

682


What are the types of pointers in c?

530


How do we print only part of a string in c?

587


can anyone suggest some site name..where i can get some good data structure puzzles???

1643


What is static volatile in c?

576


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.

1593


What are multibyte characters?

644