write a program to check whether a given integer is a strong
number or not?
[Hint:
145=1!+4!+5!
=1+24+120
=145]

Answers were Sorted based on User's Feedback



write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! ..

Answer / rajesh kumar s

void main()

{
int n,t,f=1,s=0,num;
printf("enter the num \t:");
scanf("%d",&n);
num=n;
while(num)
{
t=num%10;
f=1;
while(t)
{
f=f*t;
t--;
}
s=s+f;
num=num/10;
}
if(n==s)
printf("%d is a strong number",n);
else
printf("%d is not a strong number",n);
}

Is This Answer Correct ?    83 Yes 17 No

write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! ..

Answer / mathew varghese

#include<stdio.h>
void main()
{
int x,y,z,sum=0,h=1,t;
int factorial (int g, int k);
printf("enter a value to check whether it is strong
number...\n");
scanf("%d",&x);
printf("\nthe entered value is:::: %d \n ",x);
t=x;
while(x>0)
{
y=x%10;
x=x/10;
z=factorial(y,h);
sum=sum+z;
}
if(sum==t)
{
printf("\n %d is a strong no:\n",t);
}
else
{
printf("\n %d is not a strong no:\n",t);
}
}
int factorial (int g, int k)
{
while(g>=1)
{
k=k*g;
g=g-1;
}
return k;
}

Is This Answer Correct ?    44 Yes 24 No

write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! ..

Answer / venkat

void main()
{
int n,f=1,rem,x,res=0,i;
clrscr();
printf("enter a number");
scanf("%d",&n);
x=n;
for(;n>0;n=n/10)
{
rem=n%10;
f=1;
for(i=1;i<=rem;i++)
f=f*i;
res=res+f;
}
if(res==x)
printf("given number is a strong number");
else
printf("given number is not a strong number");
getch();
}

Is This Answer Correct ?    18 Yes 6 No

write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! ..

Answer / prasad

int fact(int);
void main()
{
int sum=0,n,f,temp;
clrscr();
printf("enter the numnber u want to check:");
scanf("%d",&n);
temp=n;
while(n>o)
{
n=n%10;
f=fact(n);
sum=sum+f;
n=n/10;
}
if(sum==temp)
{
printf("given num %d is strong number:");
else
printf("given num %d is not a strong number:");
}
getch();
}
int fact(int n)
{
if(n==0)
return(1);
else
return n*fact(n-1);
}

Is This Answer Correct ?    11 Yes 4 No

write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! ..

Answer / valli

int fact(int f)
{
if(f==1||f==0)
return 1;
else
return(f*fact(f-1));
}
main()
{
int n,i,j,s=0;
printf("enter the number");
scanf("%d",&n);
i=n;
while(n!=0)
{
j=n%10;
s=s+fact(j);
n=n/10;
}
if(i==s)
printf("strong number");
else
printf("not a strong number");
}

Is This Answer Correct ?    12 Yes 8 No

write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! ..

Answer / 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

write a program to check whether a given integer is a strong number or not? [Hint: 145=1!+4!+5! ..

Answer / dally

#include<stdio.h>
int main()
{
int n = 145;
int i,sum=0,temp;
temp = n;
while(n>1)
{
n=n%10;
sum = sum+fact(n);
printf("%d",sum);
}
if(temp == sum)
printf("Given no is STRONG number\n");
}
int fact(int a)
{
int i=1,fact=1;
fact = i*fact(--i);
return fact;
}

Is This Answer Correct ?    18 Yes 17 No

Post New Answer

More C Interview Questions

Write a program to know whether the input number is an armstrong number.

0 Answers   Wipro,


CAN ANYONE PLEASE HELP ON THIS PROGRAM FOR MY EXAM..TQ Write a C program to help a H’s Restaurant automate its breakfast billing system. Your assignment should implement the following items: a. Show the customer the different breakfast items offered by the H’s Restaurant. b. Allow the customer to select more than one item from the menu. c. Calculate and print the bill to the customer. d. Produce a report to present your complete program and show more sample output. Assume that the H’s Restaurant offers the following breakfast menu: Plain Egg $2.50 Bacon and Egg $3.45 Muffin $2.20 French Toast $2.95 Fruit Basket $3.45 Cereal $0.70 Coffee $1.50 Tea $1.80 Your program must do the following task below: a. Define the data structs, menu item types with two components: menu item of type string and menu price of type double. Use an array to declare the data structs. b. Function get data to loads the data into the array menu list. c. Function show menu to show the different breakfast items offered by the restaurant and tell the user how to select the items. d. Function print receipt to calculates and prints the customer receipt. The billing amount should include a 5% tax. e. Format your output with two decimal places. The name of each item in the output must be left-justify. You may assume that the user selects only one item of a particular type. f. The two sample output as shown: Welcome to HiFi’s Restaurant 1 Bacon and Egg $3.45 1 Muffin $2.20 1 Coffee $1.50 Tax 5% $0.35 Amount Due $7.50

1 Answers  


hi send me sample aptitude papers of cts?

0 Answers  


What is the difference between malloc calloc and realloc in c?

0 Answers  


What is the difference between null pointer and wild pointer?

0 Answers  






How do I declare a pointer to an array?

6 Answers   IBM,


what is differnence b/w macro & functions

1 Answers  


What is the benefit of using an enum rather than a #define constant?

0 Answers  


related proverb of "dont count your chicken before it hatches"

1 Answers  


how can write all 1to 100 prime numbers using for loop,if and break ?

2 Answers   TCS,


what is the difference b/w compiler and debugger?

2 Answers   Assurgent,


Is multithreading possible in c?

0 Answers  


Categories