Because you are "cout"ing the value that evenTest returns (which is garbage cuz you didn't return anything.
What you should do is:
/* a function that tests whether an integer is even,...
Type: Posts; User: Polymorphic OOP
Because you are "cout"ing the value that evenTest returns (which is garbage cuz you didn't return anything.
What you should do is:
/* a function that tests whether an integer is even,...
It's result is 1 if it's odd and 0 if it's even
so
std::cout << "Value is " << ( Value & 1 ? "odd" : "even" );
Bitwise operations are faster than division, multiplication, addition, subtraction because it's just a quick check on the bits.
Or, if you want to optimize just do:
Value & 1
if the result of the expression is true then the number was odd, if false, then the number was even