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

How #define works?

0 Answers  


who is the father of C Language?

20 Answers   CTS, UST,


to get a line of text and count the number of vowels in it

2 Answers  


How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?

2 Answers   Aricent, Manipal University,


how to find the sizof of any datatype using bit manipulations

3 Answers  






What does volatile do?

0 Answers  


Can we increase size of array in c?

0 Answers  


write a c program to calculate the income tax of the employees in an organization where the conditions are given as. (I.T. = 0 if income <100000 I.T = 10% if income _< 200000 it = 20% if income >_ 200000)

7 Answers   Consultancy, DBU, FD, JK Associates, Kobe, Satyam,


Write a program which has the following seven functions. The functions should be: • main() this calls the other 6 functions • fget_long() a function which returns a long data type from a file • fget_short() a function which returns a short integer variable from a file • fget_float() a function which returns a floating point variable from a file • fprt_long() a function which prints its single, long argument into a file • fprt_short() a function which prints its single, short argument into a file • fprt_float() a function which prints its single, floating point argument into a file. You should use fscanf() to get the values of the variables from the input (the file) and fprintf() to print the values to the other file. Pay attention to using the correct format for each of the data types.

0 Answers  


How can I rethow can I return a sequence of random numbers which dont repeat at all?

0 Answers  


At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with these names could be kept in that shelf as in this example: bottom of shelf ---> [AAAJKRDFDEWAAYFYYKK]-----Top of shelf. All these packets are to be loaded on cars. The cars are lined in order, so that the packet could be loaded on them. The cars are also named [A, B, C, D, E,………….]. Each Car will load the packet with the same alphabet. So, for example, car ‘A’ will load all the packets with name ‘A’. Each particular car will come at the loading point only once. The cars will come at the loading point in alphabetical order. So, car ‘B’ will come and take all the packets with name ‘B’ from the shelf, then car ‘C’ will come. No matter how deep in the shelf any packet ‘B’ is, all of the ‘B’ packets will be displaced before the ‘C’ car arrives. For that purpose, some additional shelves are provided. The packets which are after the packet B, are kept in those shelves. Any one of these shelves contains only packets, having the same name. For example, if any particular shelf is used and if a packet with name X is in it, then only the packets having names X will be kept in it. That shelf will look like [XXXXXXX]. If any shelf is used once, then it could be used again only if it is vacant. Packets from the initial shelf could be unloaded from top only. Write a program that finds the minimum total number of shelves, including the initial one required for this loading process.

0 Answers   Infosys,


How can I change their mode to binary?

0 Answers  


Categories