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

What are the properties of union in c?

0 Answers  


how should functions be apportioned among source files?

0 Answers  


how to execute with out main in cprogram

15 Answers   Infosys,


which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;

0 Answers  


where does malloc() function get the memory?

1 Answers  






Is it possible to have a function as a parameter in another function?

0 Answers  


proc() { static i=10; printf("%d",i); } If this proc() is called second time, what is the output?

7 Answers   Hughes,


Tell me what are bitwise shift operators?

0 Answers  


What is a floating point in c?

0 Answers  


write a pgm to print 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1

3 Answers  


What is a lookup table in c?

0 Answers  


What is the difference between test design and test case design?

0 Answers  


Categories