ctrucza
11/13/2008 6:26:00 PM
On Nov 13, 5:18 pm, "reepakmajhi....@gmail.com"
<reepakmajhi....@gmail.com> wrote:
> Solve this Question
> Write a Program to find a number is even or odd?
how about this:
bool is_even(int n)
{
return ( (n == 0) || (n == 2) || (n == 4) || ... || (n ==
2*K) ); // for a carefully chosen value of K
}
Of course this will work correctly only for positive integers smaller
or equal than 2*K.
Extending it to work for negative numbers and other values of K is
fairly trivial.