+ 2

It is possible to chack The given number is even or odd without using rimender Opreter in ç++

6th Mar 2018, 7:38 PM
Abhay Upadhyay
Abhay Upadhyay - avatar
3 Answers
+ 6
You can use the binary & to check the least significant bit. if(num & 1){ /* odd */ } else { /* even */ }
6th Mar 2018, 7:42 PM
Schindlabua
Schindlabua - avatar
+ 4
or... if(typeof num/2=="integer") //even if(typeof num/2=="float") //odd
6th Mar 2018, 7:54 PM
᠌᠌Code X
᠌᠌Code X - avatar
+ 1
while(num>0) {num-=2; if(num==0) { alert("even"); break; } else{ alert("odd"); break; } }
6th Mar 2018, 7:43 PM
᠌᠌Code X
᠌᠌Code X - avatar