#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();
}
Chat with our AI personalities
#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
#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:
***/
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);
}
The greatest number is infinity.
printf(\n "ENTER THE NUMBER\t"); scanf{"%d",&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",&a); } getch(); }
Yes
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 program to find the number and sum of all integers from 100 to 300 that are divisible by 11