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

#include<stdio.h>
main()
{
int n,sum=0,r,f=1,i=1,m;
printf("enter anumber");
scanf("%d",&n);
m=n;
while(n>0)
{
r=n%10;
for(i=1;i<=r;i++)
f=f*i;
sum=sum+f;
n=n/10;
}
if(sum==m)
printf("the given number is strong number");
else
printf("the given number is not a strong number");
}

Is This Answer Correct ?    27 Yes 11 No

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

Answer / vetrivel

#include<stdio.h>
int fact(int r)
{
if(r=0 || r=1)
return 1;
else
return(r*fact(r-1);
}
void main()
{
int a,n,rem,sum=0
printf("Enter the number\n");
scanf("%d",&n);
a=n;
while(n!=0)
{
rem=n%10;
sum=sum+fact(rem);
n=n/10;
}
if(sum==a)
printf("%d is a strong number",a);
else
printf("%d is not a strong number",a);
}

Is This Answer Correct ?    8 Yes 5 No

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

Answer / abhijit

using System;
using System.Collections.Generic;
using System.Text;

namespace Practice
{
class Program
{
public static int fact(int r)
{
if (r == 0 || r == 1)
return 1;
else
return (r * fact(r - 1));
}
static void Main(string[] args)
{
args = new string[1];
args[0] = Console.ReadLine();

int n, tmp, rem, sum = 0;

int ii = fact(5);
n = Convert.ToInt32(args[0]);
tmp = n;
int jj=0;
while (n != 0)
{
rem = n % 10;

jj=fact(rem);
sum = sum + jj;
n = n / 10;
}

if (tmp == sum)
Console.WriteLine(tmp + "is a strong number");
else
Console.WriteLine(tmp + " is not a strong number");
Console.ReadLine();
}


}
}

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

#include<stdio.h>
main()
{
int n,sum=0,r,f=1,i=1,m;
printf("enter anumber");
scanf("%d",&n);
m=n;
while(n>0)
{
r=n%10;
for(i=1,f=1;i<=r;i++)
f=f*i;
sum=sum+f;
n=n/10;
}
if(sum==m)
printf("the given number is strong number");
else
printf("the given number is not a strong number");
}

Is This Answer Correct ?    7 Yes 6 No

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

Answer / amolraje lendave

#include<iostream.h>
#include<conio.h>
int main()
{
int j,t,n,r,s=0,i,f=1;
clrscr();
for(j=3;j<=1000;j++)
{
s=0;
n=j;
while(n>0)
{
f=1;
r=n%10;
for(i=1;i<=r;i++)
{
f=f*i;
}
s=s+f;
n=n/10;
}
if(j==s)
{
cout<<j<<endl;
}
else
continue;
}
getch();
return 0;
}

Is This Answer Correct ?    1 Yes 0 No

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

Answer / nabanita dutta

#include<stdio.h>
#main()
{
int n,sum=0,r,f=1,i=1,m;
printf("enter anumber");
scanf("%d",&n);
m=n;
while(n>0)
{
r=n%10;
for(i=1,f=1;i<=r;i++)
f=f*i;
sum=sum+f;
n=n/10;
}
if(sum==m)
printf("the given number is strong number");
else
printf("the given number is not a strong number");
}

Is This Answer Correct ?    0 Yes 0 No

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

Answer / chandan verma

#include<stdio.h>
#include<conio.h>
void main()
{
int n,tmp,rem,sum=0;
printf("enter a number");
scanf("%d",&n);
tmp=n;
while(n!=0)
{
rem=n%10;
sum+=rem*rem*rem;
n=n/10;
}
if(tmp==sum)
printf("%d is a strong no",tmp);
else
printf("%d is not a strong no",tmp);
getch();
}
printf(

Is This Answer Correct ?    20 Yes 31 No

Post New Answer

More C Interview Questions

to find out the reverse digit of a given number

6 Answers   Infosys, Microsoft, TCS, Wipro,


How to print %d in output

6 Answers   Wipro,


array of pointer pointer to array pointer to pointer

1 Answers   MAHINDRA,


Write a programe print the sum of series 0,1,2,.....10

7 Answers  


What is c variable?

0 Answers  






What are the uses of null pointers?

0 Answers  


A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream

0 Answers  


write a program for even numbers?

19 Answers   TCS,


what does exit() do?

3 Answers   Cadence,


what's the return value of malloc()

9 Answers  


20. main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); } Answer:??????

2 Answers  


What is the use of static variable in c?

0 Answers  


Categories