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 / prasad
int fact(int);
void main()
{
int sum=0,n,f,temp;
clrscr();
printf("enter the numnber u want to check:");
scanf("%d",&n);
temp=n;
while(n>o)
{
n=n%10;
f=fact(n);
sum=sum+f;
n=n/10;
}
if(sum==temp)
{
printf("given num %d is strong number:");
else
printf("given num %d is not a strong number:");
}
getch();
}
int fact(int n)
{
if(n==0)
return(1);
else
return n*fact(n-1);
}
| Is This Answer Correct ? | 11 Yes | 4 No |
Post New Answer View All Answers
Write programs for String Reversal & Palindrome check
Can you assign a different address to an array tag?
Is array name a pointer?
Why does this code crash?
What is the method to save data in stack data structure type?
Why do we use stdio h and conio h?
.main() { char *p = "hello world!"; p[0] = 'H'; printf("%s",p); }
Is null a keyword in c?
How can I rethow can I return a sequence of random numbers which dont repeat at all?
What is spaghetti programming?
a program that can input number of records and can view it again the record
what are the different storage classes in c?
i = 25;switch (i) {case 25: printf("The value is 25 ");case 30: printf("The value is 30 "); When the above statements are executed the output will be : a) The value is 25 b) The value is 30 c) The value is 25 The value is 30 d) none
Write a program to reverse a given number in c?
What is calloc in c?