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
What is meant by type specifiers?
What is c value paradox explain?
How can I get the current date or time of day in a c program?
Why c is called a mid level programming language?
Explain is it better to bitshift a value than to multiply by 2?
Is c still used?
What is the description for syntax errors?
Are pointers integer?
What is getche() function?
Explain how do you determine a file’s attributes?
in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none
What is variable and explain rules to declare variable in c?
What is a far pointer in c?
What is meant by keywords in c?
what is different between auto and local static? why should we use local static?