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 / mathew varghese
#include<stdio.h>
void main()
{
int x,y,z,sum=0,h=1,t;
int factorial (int g, int k);
printf("enter a value to check whether it is strong
number...\n");
scanf("%d",&x);
printf("\nthe entered value is:::: %d \n ",x);
t=x;
while(x>0)
{
y=x%10;
x=x/10;
z=factorial(y,h);
sum=sum+z;
}
if(sum==t)
{
printf("\n %d is a strong no:\n",t);
}
else
{
printf("\n %d is not a strong no:\n",t);
}
}
int factorial (int g, int k)
{
while(g>=1)
{
k=k*g;
g=g-1;
}
return k;
}
Is This Answer Correct ? | 44 Yes | 24 No |
Post New Answer View All Answers
Explain the bubble sort algorithm.
what is the syallabus of computer science students in group- 1?
hi folks i m approching for h1 b interview on monday 8th of august at montreal and i m having little problem in my approval notice abt my bithdate my employer has made a mistake while applying it is 12th january and istead of that he had done 18 the of january do any body have any solution for that if yes how can i prove my visa officer abt my real birthdate it urgent please let me know guys thaks dipesh patel
What is the difference between union and anonymous union?
Explain the difference between the local variable and global variable in c?
explain what is fifo?
Can you write the algorithm for Queue?
What are structures and unions? State differencves between them.
Explain what is a program flowchart and explain how does it help in writing a program?
List out few of the applications that make use of Multilinked Structures?
What is main () in c language?
C program to find all possible outcomes of a dice?
What does struct node * mean?
What are disadvantages of C language.
What is the difference between array and structure in c?