What the output of this question? bool y=5; cout<<y/2<<endl; | Sololearn: Learn to code for FREE!

+1

What the output of this question? bool y=5; cout<<y/2<<endl;

All the numbers in the language c++, shall be true except zero is false

3/13/2017 4:25:00 AM

Nour Alnaser

6 Answers

New Answer

+10

don't have a compiler to test it but I guess it will output 0. bool y=5; => y=true; cout << y/2 ( true / 2 = 1 / 2 = 0 ) << endl;

+2

yes the output is 0 ... thank you πŸ™‚

+2

yes exactly it is 0! cool! never thought about it

+1

Yes, it is, but more,try this code bool y=5; cout<<y; So, All the numbers in the language c++ are true, but after store into bool variable there is only 1 value,

+1

it outputs 0

+1

We can make this kind program for java