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 / paul zarkovich

#include<iostream>
#include<stdio.h>
#include<conio.h>

using namespace std;

main()
{
int n,fact=1,sum=0,digit=0;

printf("Enter a number : ");
scanf("%d",&n);

int temp=n,a=n;

if(temp<10)
{
for(int i=temp;i>0;i--)
fact*=i;

if(n==fact)
printf("It is a strong no. ");
else
printf("It is not a strong no. ");
}

else
{
while(temp>10)
{
digit=temp%10;

temp/=10;

for(int i=digit;i>0;i--)
fact*=i;

sum+=fact;
fact=1;
}
for(int i=temp;i>0;i--)
fact*=i;

sum+=fact;
if(sum==n)
printf("It is a strong no. ");
else
printf("It is not a strong no. ");

}

getch();
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the features of the c language?

641


What is the purpose of sprintf() function?

597


#include #include struct stu { int i; char j; }; union uni { int i; char j; }; void main() { int j,k; clrscr(); struct stu s; j=sizeof(s); printf("%d",j); union uni u; k=sizeof(u); printf("%d",k); getch(); } what is value of j and k.

5194


Can you subtract pointers from each other? Why would you?

558


What is the difference between typedef and #define?

541






What is pointer to pointer in c with example?

545


Are c and c++ the same?

624


Is it better to use a macro or a function?

651


What is an array in c?

593


Is c pass by value or reference?

593


What library is sizeof in c?

569


What is typedf?

665


Why doesnt the call scanf work?

666


How main function is called in c?

625


What functions are used for dynamic memory allocation in c language?

597