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 is FIFO?
What is || operator and how does it function in a program?
How can I manipulate individual bits?
struct screen_pos{ int row, col } ;move_right(cursor)struct screen_pos *cursor;{ cursor.col++; } /* This statementhas a syntax error */What is the correct statement a) cursor.col = cursor.col + 1; b) col.cursor++; c) *cursor.col++; d) pointer
Tell me what is the purpose of 'register' keyword in c language?
Is void a keyword in c?
What do you mean by Recursion Function?
pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)
what do you mean by inline function in C?
What is 02d in c?
How do I round numbers?
When should you not use a type cast?
Explain null pointer.
Why do we use return in c?
The __________ attribute is used to announce variables based on definitions of columns in a table?