doubt with a code in C++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

doubt with a code in C++

Why this code results in "0"? int a=10; int main() { cout<<(a==9) }

15th Feb 2020, 7:06 PM
LUIS MANUEL LOPEZ SEPULVEDA
7 Answers
+ 2
0 means condition result is false because a is not equal to 9
15th Feb 2020, 7:14 PM
Mukul Singh Bhist
Mukul Singh Bhist - avatar
+ 2
0 because 10 is not equal to 9.i think you have to include <stdbool.h> for using bool.
17th Feb 2020, 2:14 AM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar
+ 1
0 means condition result is false because a is not equal to 9
16th Feb 2020, 6:01 AM
robin kansal
robin kansal - avatar
+ 1
0
16th Feb 2020, 3:48 PM
Jagbir singh
Jagbir singh - avatar
0
If a=10, I understand that in the next line, "a" keeps te value, and then test equal to 9, but I don´t undertsand why the result is "0"
15th Feb 2020, 7:12 PM
LUIS MANUEL LOPEZ SEPULVEDA
0
Thanks a lot Roman J, for the clarification Best Regards
15th Feb 2020, 7:15 PM
LUIS MANUEL LOPEZ SEPULVEDA
0
Where u use (9==10) its treat like if, else condition. here 9 is not equal to 10 so condition false and output become 0
16th Feb 2020, 10:10 AM
A S Raghuvanshi
A S Raghuvanshi - avatar