in isodd function ? the return type was bool
that is for the num. 5 the output should be true rather than 1
In isodd function?
true is equivalent to 1 and false equivalent to 0
so
when we return true from the function 1 is obtained
and false gives output 0
but the return type was bool
then true should be printed
see bool is 0 or 1
so
in case u require the o/p to be true or false
u can use
(fn() == 0 )? (cout <<“false” ): cout <<“true”;
the bool function always returns 0 or 1
1 Like