+ 2

Find a number the number which is entered by the user is even or odd without using modules (%) operator?

not use the ℅ operator in a whole program there are two ways to write this program other then % operator..

10th Nov 2016, 6:13 AM
DEATH WALKER
DEATH WALKER - avatar
3 Respuestas
+ 3
simple solution is: if((number / 2)*2==number) { printf(" Even number"); } else { printf("Odd Number"); }
10th Nov 2016, 6:57 AM
Harish Nandoliya
Harish Nandoliya - avatar
+ 2
#include<iostream> #include<cmath> using namespace std; int main() { int a; cin>>a; a = abs(a); if((a/2) == (a+1)/2) cout<<"even"<<endl; else cout<<"odd"<<endl; }
10th Nov 2016, 7:01 AM
kamal joshi
kamal joshi - avatar
+ 1
there is one more way any one tell me..
10th Nov 2016, 7:21 AM
DEATH WALKER
DEATH WALKER - avatar