How to write a program to find a number is even or odd. Print "even" or "odd" on screen conditions : don't use / % conditional statements if else switch and loops for while & do while | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How to write a program to find a number is even or odd. Print "even" or "odd" on screen conditions : don't use / % conditional statements if else switch and loops for while & do while

26th Jun 2016, 6:59 AM
Ramesh Marisa
8 Answers
+ 1
std::string array [2] = { "Even", "Odd" }; int a = 10; cout <<array [ a & 1]; It's solvable and enjoy
27th Jun 2016, 8:13 AM
Venkatesh(Venki)
Venkatesh(Venki) - avatar
- 1
are you sure not to use if-else? without if-else...the question seems unsolvable
26th Jun 2016, 7:33 AM
Mukul Kumar
Mukul Kumar - avatar
- 1
it is solvable without if-else
26th Jun 2016, 7:56 AM
Ramesh Marisa
- 1
No, any conditional statements are not needed
26th Jun 2016, 8:01 AM
Ramesh Marisa
- 1
my mind's not working....anyone got some idea???
26th Jun 2016, 8:08 AM
Mukul Kumar
Mukul Kumar - avatar
- 1
I don't think its possible
26th Jun 2016, 10:31 AM
Janit Pathak
Janit Pathak - avatar
- 1
If it's an integral number you have to check if the last bit is set. If so, it's uneven. Go from there.
26th Jun 2016, 1:16 PM
Stefan
Stefan - avatar
- 1
no idea , may be its unsolvable
16th Jul 2016, 5:05 AM
Karan Luther
Karan Luther - avatar