What is conditional operator ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is conditional operator ?

hi friends what is conditional operators

28th Apr 2017, 12:34 PM
Zohaib Afridi
Zohaib Afridi - avatar
3 Answers
+ 4
The conditional operator is also called ternary operator, because it's structure consists of three parts: ? : ; Example: [return] = [condition] ? [return if condition is true] : [return if condition false]; What the ternary operator is doing is first evaluating the [condition]. If it is true it will assign [return] the value [return if condition is true], otherwise it will assign [return] the value [return if condition is false]. Here is a nice picture that summerizes what I just said above: http://img.c4learn.com/2012/02/Conditional-Statement-in-C-Programming-Lanuage-Ternary-Operator.png
28th Apr 2017, 1:09 PM
Thanh Le
Thanh Le - avatar
+ 2
if my answer was of any help to you, then please consider marking it as the best answer. Thanks in advance.
23rd May 2017, 9:29 AM
Thanh Le
Thanh Le - avatar
+ 1
Thanks bro
23rd May 2017, 9:06 AM
Zohaib Afridi
Zohaib Afridi - avatar