Is there another way to do if and else. (C++ QUESTION) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is there another way to do if and else. (C++ QUESTION)

Like, switch, case and default are the same as if and else but different command.

22nd Oct 2021, 12:10 AM
Idris
Idris - avatar
4 Answers
+ 1
The ternary operator is another option. (<condition> ? <true expression> : <false expression>)
22nd Oct 2021, 2:44 AM
Brian
Brian - avatar
+ 2
Brian I think you mean ternary operator. 😉😁
22nd Oct 2021, 3:46 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
Oh thanks guys, wouldn’t had know it without you!
22nd Oct 2021, 9:42 AM
Idris
Idris - avatar
+ 1
ChaoticDawg oops! Yes, ternary. I was a little distracted when I typed that. Thank you, friend! I corrected it.
22nd Oct 2021, 5:31 AM
Brian
Brian - avatar