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 external variable in c?
Explain what is a const pointer?
What are the properties of union in c?
What are the different types of control structures?
How do you initialize pointer variables?
Define C in your own Language.
When can a far pointer be used?
What does sizeof return c?
What is cohesion and coupling in c?
What does s c mean on snapchat?
Write a program which returns the first non repetitive character in the string?
What does 2n 4c mean?
writ a program to compare using strcmp VIVA and viva with its output.
Is main is a keyword in c?
Design a program which assigns values to the array temperature. The program should then display the array with appropriate column and row headings.