The number 170 is even.
For any number n you could use * (n % 2 == 0), which would be true for an even number, false for odd For an integer i, a simpler method would be * (i & 1), which would be true for an odd number, false for even
If you add, subtract, or multiply two even numbers, you will get an even number. If you divide an even number by another even number, you may get an even number, an odd number, or even a fraction.
The pseudo code would be as follows (you figure out the syntax) 1) Prompt the user to enter a number 2) If entered number is alpha, quit program after displaying message that the user ended the program. 3) Otherwise, find Modulo 2 of the entered number. This is a fancy way of saying "find the remainder when the number is divided by 2) 4) If Modulo 2 is zero, the number is even, otherwise odd 5) Display message showing if the entered number was Even or Odd 6) Branch back to step 1
int main () { int x; printf ("Enter the value of x\n"); scanf ("%d",&x); if (0 == x%2) printf ("Number is even\n") else printf ("Number is odd\n"); }
To write a C program to determine if something is odd or even you need to be a programmer. To write a program in C is complicate and only done by programmers.
The number 170 is even.
For any number n you could use * (n % 2 == 0), which would be true for an even number, false for odd For an integer i, a simpler method would be * (i & 1), which would be true for an odd number, false for even
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(); }
A prime number is any number that only has only one and itself as factors. By definition even numbers have a factor of two. Therefore the only even number that is prime is the number 2.
if n MOD 2 == 0 THEN Write ("Even");
If you add, subtract, or multiply two even numbers, you will get an even number. If you divide an even number by another even number, you may get an even number, an odd number, or even a fraction.
Reference:http:cprogramming-bd.com/c_page2.aspx# strange number
The pseudo code would be as follows (you figure out the syntax) 1) Prompt the user to enter a number 2) If entered number is alpha, quit program after displaying message that the user ended the program. 3) Otherwise, find Modulo 2 of the entered number. This is a fancy way of saying "find the remainder when the number is divided by 2) 4) If Modulo 2 is zero, the number is even, otherwise odd 5) Display message showing if the entered number was Even or Odd 6) Branch back to step 1
int main () { int x; printf ("Enter the value of x\n"); scanf ("%d",&x); if (0 == x%2) printf ("Number is even\n") else printf ("Number is odd\n"); }
echo "Enter the Number" read n r=`expr $n % 2` if [ $r -eq 0 ] then echo "$n is Even number" else echo "$n is Odd number" fi
You can use int i; for (i = 10; i <= 50; i += 2) {//print i} as a program to print even numbers between 10 and 50.