xxxxxxxxxx
#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
xxxxxxxxxx
// @Author: Subodh
// 1 liner solution
(num & 1) ? cout << num << " is odd" : cout << num << " is even" << endl;
xxxxxxxxxx
/* 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;
}
xxxxxxxxxx
<?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";
}
?>
xxxxxxxxxx
#include<iostream>
using namespace std;
int main() {
int num;
cout<<"enter a number /n";
cin>> num ;
if(num % 2 == 0){
cout<<num<<" is an even number"<<endl;
}
else{
cout<<num<<" is an odd number"<<endl;
}
return 0;
}