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
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?
How are portions of a program disabled in demo versions?
What is the scope of local variable in c?
Mention four important string handling functions in c languages .
Write a C program on Centralized OLTP, Decentralized OLTP using locking mechanism, Semaphore using locking mechanism, Shared memory, message queues, channel of communication, sockets and a simple program on Saving bank application program using OLTP in IPC?
What is meant by recursion?
What is uint8 in c?
difference between native and cross compilers
What are keywords c?
Differentiate between a structure and a union.
Tell me what are bitwise shift operators?
How do you define a string?
What are the different types of data structures in c?
What are the storage classes in C?
Sir i need notes for structure,functions,pointers in c language can you help me please