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
write a programming in c to find the sum of all elements in an array through function.
What standard functions are available to manipulate strings?
Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.
What are the general description for loop statement and available loop types in c?
how to print electricity bill according to following charges first 100 units -1rs per unit for next 200 units-1.50 rs per unit without using conditions
List the difference between a While & Do While loops?
Explain how can I convert a string to a number?
write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.
What is wrong with this initialization?
hi to every one .. how to view table pool after creating the pooled table? plz help me.. if any knows abt this ..
Explain b+ tree?
Can we add pointers together?
What is main function in c?
Explain union.
What are structure members?