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

Differentiate Source Codes from Object Codes

807


What is the use of a static variable in c?

585


Explain about the constants which help in debugging?

841


Are bit fields portable?

669


"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks

650






What is mean by data types in c?

545


What is a newline escape sequence?

659


The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none

701


How do I swap bytes?

626


What is a null string in c?

577


What is 1f in c?

1823


How many parameters should a function have?

659


pierrot's divisor program using c or c++ code

1720


What is an lvalue in c?

687


a function gets called when the function name is followed by a a) semicolon (;) b) period(.) c) ! d) none of the above

858