#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
I assume you mean is an if the number is an integer multiple of 3i am unfamiliar with C but the theory would be,find if a is integer multiple of 3b=a/3b==round(b).if 1 "yes"else "no"this is an inefficiency way but will get the job done
The greatest number is infinity.
/* 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
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
sir , what is perfect no?
whereis [name of program]
square and cube caculator
sdfsdfsfsggbcvbg
the odds against evens
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
k
syntax error