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 / vetrivel
#include<stdio.h>
int fact(int r)
{
if(r=0 || r=1)
return 1;
else
return(r*fact(r-1);
}
void main()
{
int a,n,rem,sum=0
printf("Enter the number\n");
scanf("%d",&n);
a=n;
while(n!=0)
{
rem=n%10;
sum=sum+fact(rem);
n=n/10;
}
if(sum==a)
printf("%d is a strong number",a);
else
printf("%d is not a strong number",a);
}
| Is This Answer Correct ? | 8 Yes | 5 No |
Post New Answer View All Answers
What are # preprocessor operator in c?
What is assignment operator?
write a program in c language to print your bio-data on the screen by using functions.
Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"
Did c have any year 2000 problems?
What is the value of c?
What are the types of type qualifiers in c?
How can I rethow can I return a sequence of random numbers which dont repeat at all?
What is #define size in c?
Explain pointer. What are function pointers in C?
What is a function simple definition?
What is the function of this pointer?
What is the difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25
What is wrong with this program statement? void = 10;
in linking some of os executables are linking name some of them