if ( n % 2 == 0 ) {
// n is even
}
else {
//otherwise odd
}
// @Author: Subodh
// 1 liner solution
(num & 1) ? cout << num << " is odd" : cout << num << " is even" << endl;
/* Program to check whether the input integer number
* is even or odd using the modulus operator (%)
*/
#include<stdio.h>
int main()
{
// This variable is to store the input number
int num;
printf("Enter an integer: ");
scanf("%d",&num);
// Modulus (%) returns remainder
if ( num%2 == 0 )
printf("%d is an even number", num);
else
printf("%d is an odd number", num);
return 0;
}
#check wheather a is odd or even
'''interactive mode
>>> 10%2
0....................False #(False==0)
>>> 5%2
1....................True #(True==1)'''
#scriptive mode
a=int(input('enter:'))
if a%2:
print("its odd")#solution gives true if 'a' value is even
else:
print("its even")#solution gives false if 'a' value is odd
print('hope it helped')
#output
#False
enter:100
its even
hope it helped
#even
enter:101
its odd
hope it helped
<?php
$check1 = 3534656;
$check2 = 3254577;
if($check1%2 == 0) {
echo "$check1 is Even number <br/>";
} else {
echo "$check1 is Odd number <br/>";
}
if($check2%2 == 0) {
echo "$check2 is Even number";
} else {
echo "$check2 is Odd number";
}
?>
def is_even(num):
return not bool(num % 2)