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
Why is c called c not d or e?
What is hungarian notation? Is it worthwhile?
Explain bit masking in c?
What 'lex' does?
How to write a program for machine which is connected with server for that server automatically wants to catch the time for user of that machine?
What is an identifier?
How can I recover the file name given an open stream or file descriptor?
provide an example of the Group by clause, when would you use this clause
Explain which function in c can be used to append a string to another string?
find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2
string reverse using recursion
Differentiate Source Codes from Object Codes
What are global variables?
What is the purpose of main() function?
Suppose we have a table name EMP as below. We want to perform a operation in which, I want to change name ‘SMITH’ from as ‘SMITH JAIN’. Also I want to change the name of the column from ENAME to E_NAME. EMPNO ENAME JOB MGR HIREDATE SAL 7369 SMITH Coder 7902 17-DEC-80 800 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 7521 WARD SALESMAN 7698 22-FEB-81 1250