How will the compiler work when we simply pass a value in if statement For eg. If(32) Cout<<"true"; Else Cout<<"false"; | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How will the compiler work when we simply pass a value in if statement For eg. If(32) Cout<<"true"; Else Cout<<"false";

20th Sep 2017, 4:09 PM
dhiman mishra
dhiman mishra - avatar
2 Answers
0
It will turn the value into a boolean value. In many languages, e.g. C++, 0 is equal to false and any other number (including negatives) represents true. As a result for every other value than 0 the if-statement will be executed, otherwise the optional else-statement.
20th Sep 2017, 5:50 PM
Shadow
Shadow - avatar
0
Thanks brother
21st Sep 2017, 3:54 AM
dhiman mishra
dhiman mishra - avatar