answersLogoWhite

0


Best Answer

#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
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

#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

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

#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.

***/

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

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);

}

This answer is:
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
Related questions

Program to find the greatest number?

The greatest number is infinity.


Java source code to find prime number?

/* Program to Find whether number is Prime or Not. */ class PrimeNo{ public static void main(String args[]){ int num = Integer.parseInt(br.readLine()); int flag=0; for(int i=2;i


Any integer is input through the keyboard write a c program to find out whether it is an odd number or even number?

printf(\n "ENTER THE NUMBER\t"); scanf{"%d",&amp;a); while(a!=0); { r=a%2; if(r==0) printf("\n\n THE NUMBER IS EVEN \t"); else printf("\n\n THE NUMBER IS ODD \t"); printf ("\n ENTER THE NUMBER \t"); scanf("%d",&amp;a); } getch(); }


Can you get a Java program to find the cube of a number?

Yes


To find strong number in java?

sir , what is perfect no?


What is the Linux command to find whether a particular software such as gromacs is installed in the system?

whereis [name of program]


Program to find square and cube of a number?

square and cube caculator


Do an 8086 assembler program to find parity of a given number?

sdfsdfsfsggbcvbg


How do you find a number whether its a power of 2 or not?

the odds against evens


How do you find whether a given number is even or odd in Unix shell programming?

echo "Program to check even or odd number"echo "Enter a number"read na=`expr $n % 2`if [ $a -eq 0 ] ; then #Semicolon is most important for Executing ifelse statementsecho "It is an even number"elseecho "It is an odd number"fi


Write a Shell program to find the smallest number from a set of numbers?

k


Shell program to find the smallest digit of a given number?

syntax error