answersLogoWhite

0

#include<stdio.h>

void main()

{

int n,t,sum=0;

float fact=1;

clrscr();

printf("enter the number");

scanf(%d",&n);

t=n;

while(t)

{

for(i=0;i<=t%10;i++)

{

fact=fact*i;

}

sum=sum+fact;

fact=1;

t=t/10;

}

if(n==sum)

{

printf("strong number");

}

else

{

printf("not strong number");

}

getch();

}

User Avatar

Wiki User

14y ago

Still curious? Ask our experts.

Chat with our AI personalities

JordanJordan
Looking for a career mentor? I've seen my fair share of shake-ups.
Chat with Jordan
ProfessorProfessor
I will give you the most educated answer.
Chat with Professor
LaoLao
The path is yours to walk; I am only here to hold up a mirror.
Chat with Lao
More answers

#include

int main(){

int

num,i,f,r,sum=0,temp;

printf("Enter a

number: ");

scanf("%d",&num);

temp=num;

while(num){

i=1,f=1;

r=num%10;

while(i<=r){

f=f*i;

i++;

}

sum=sum+f;

num=num/10;

}

if(sum==temp)

printf("%d is a

strong number",temp);

else

printf("%d is

not a strong

number",temp);

return 0;

}

Sample output:

Enter a number: 145

145 is a strong number

User Avatar

Wiki User

13y ago
User Avatar

#include

#include

#include

int main(int argc, char *argv[]){

int numval, calcval;

int tally, digit, numdigits, n;

// first, read the number passed

if(argc != 2){

printf("This program requires one numeric argument");

return 1;

}

calcval = numval = abs(atoi(argv[1]));

// now count the digits

numdigits = 0;

while(calcval > 0){

numdigits ++;

calcval /= 10;

}

// and calculate whether it's an Armstrong number or not

calcval = numval;

tally = 0;

while(calcval > 0){

digit = calcval % 10;

calcval -= digit;

calcval /= 10;

for(n = 1; n < numdigits; n++){

digit *= digit;

}

tally += digit;

}

// now display the results

if(tally == numval){

printf("%i is an Armstrong number.\n", numval);

}else{

printf("%i is an not Armstrong number.\n", numval);

}

return 0;

}

/***

Note that you can convert this to determine an Armstrong number in ~any~ numeric base pretty easily. It would be done this way:

  1. Accept a second argument, the base in which the number is expressed.
  2. Replace the call to atoi with a custom function that converts the string to a value in a specified base.
  3. Replace the lines that use division by ten or modulus ten with the same operation on the specified base.

***/

User Avatar

Wiki User

13y ago
User Avatar

The sample code is as follows:

#include <stdio.h>

void main()

{

int i = 0,k = 0;

int number = 0, temp = 0, temp1 = 0, sum = 1, sum1 = 0;

printf("Strong Number check: Enter the number\n");

scanf("%d", &number);

temp = number;

while(number > 0 )

{

temp1 = number % 10;

number = number / 10;

for(k = temp1; k > 1; k--) {

sum *= k;

}

sum1 += sum;

sum = 1;

}

i = (sum1 == temp) ? printf("%d = Strong Number", temp) : printf("%d = Not Strong Number", temp);

}

User Avatar

Wiki User

12y ago
User Avatar

Add your answer:

Earn +20 pts
Q: C program to find whether is strong number or not?
Write your answer...
Submit
Still have questions?
magnify glass
imp