What is the use of ternary operator in c++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the use of ternary operator in c++?

7th Mar 2019, 2:03 PM
Akash Gite
Akash Gite - avatar
2 Answers
+ 8
Another way to write an if else part. if (x==5) cout << "howdy"; else cout << "bye"; equals cout << (x==5? "howdy": "bye");
7th Mar 2019, 2:10 PM
HonFu
HonFu - avatar
+ 3
Its use is to allow using conditions in the middle of a statement
7th Mar 2019, 3:52 PM
Bebida Roja
Bebida Roja - avatar