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

a=0; while(a<5) printf("%d\n",a++); how many times does the loop occurs? a.infinite b.5 c.4 d.6

7 Answers   TCS,


find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2

0 Answers   TCS,


How do i store a paragraph into a string? for example, if i input a long paragraph, the program will read the words one by one and concatenate them until no word is left.

1 Answers  


how can i get output the following... 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 and 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 plz plz...

3 Answers  


Write a C++ program without using any loop (if, for, while etc) to print numbers from 1 to 100 and 100 to 1;

18 Answers   Accenture, Cisco, Egentec, HCL, Ideaz, Infosys, M-Systems, MYR, TCS,






What does #pragma once mean?

0 Answers   Celstream,


difference between c and c++

3 Answers  


Explain how can I avoid the abort, retry, fail messages?

0 Answers  


Explain high-order bytes.

0 Answers  


What is call by value in c?

0 Answers  


What are the average number of comparisons required to sort 3 elements?

2 Answers   DRDO,


How can I remove the leading spaces from a string?

0 Answers  


Categories