For + the variable is sum what is the variable for < > | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

For + the variable is sum what is the variable for < >

4th Mar 2021, 6:30 AM
Astro ytr
Astro ytr - avatar
7 Answers
+ 3
Nazeekk You need to place them in parenthesis, and then they will output 0 for false or 1 for true. cout << (5 > 6); // outputs 0 cout << (5 < 6); // outputs 1 etc
4th Mar 2021, 7:51 AM
ChaoticDawg
ChaoticDawg - avatar
+ 3
Nazeekk Oh, and if you really wanted to output true or false instead then you could use a ternary like; cout << (5 < 6? "true": "false");
4th Mar 2021, 7:57 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
Nazeekk No worries, I'm pretty rusty and was never really great at c++
4th Mar 2021, 8:40 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Thats conditional operator. They're needed to check the statement. Just like cout << 5 > 6; //output will be "false" cout << 5 < 6; //output will be "true" cout << 5 == 5; //output will be "true" cout << 5 == 6; //output will be "false" cout << 5 != 6 //output will be "true" cout << 5 != 5 //output will be "false"
4th Mar 2021, 6:35 AM
Nazeekk
Nazeekk - avatar
+ 1
ouch, im sorry, in c++ it doesn't works with "cout". But anyway, you can do the same using "if" statement
4th Mar 2021, 6:37 AM
Nazeekk
Nazeekk - avatar
+ 1
for example: if(6 > 5) { cout<<"6 is greater then 5"; } else if(6 < 5) { cout<<"5 is greater than 6"; } //output gonna be "6 is greater than 5"
4th Mar 2021, 6:39 AM
Nazeekk
Nazeekk - avatar
0
ChaoticDawg Thanks for it. Im kinda bad in C++😃😃
4th Mar 2021, 8:38 AM
Nazeekk
Nazeekk - avatar