<h2>
Answer:</h2>
A ternary operator, also called a conditional operator, is a special kind of operator used in some programming languages as a shorter way of writing an if..else block. It is denoted by a question mark and then a colon (? : ). It takes 3 operands:
i. <em>A boolean expression </em>which would evaluate to a true or a false.
ii. <em>A first value</em> that will be assigned if the boolean expression gives a true.
iii. <em>A second</em> <em>value</em> that will be assigned if the boolean expression gives a false.
The general format is:
<em>variable = boolean expression ? first_value : second_value;</em>
<em>For example:</em>
A ternary expression can be written as;
String f = (3 > 5) ? "yes" : "no";
In the above expression;
The boolean expression is 3 > 5
The value to be assigned, to <em>f</em>, if the boolean expression is true is "yes"
The value to be assigned, to <em>f</em>, if the boolean expression is false is "no"
So in this case, since (3 > 5) evaluates to false, "no" will be assigned to <em>f.</em>
Therefore, the above expression will give the same result as;
String f = "no"
<em>Another example:</em>
=================
int a = 5:
int b = 3;
int max = (a > b)? a : b;
==================
In the above code snippet,
Since a > b i.e 5 > 3, the first value <em>a </em><em>(which is equal to 5) </em>will be assigned to max.
Therefore, int max = 5.
The value of max is <em>5</em>
<em></em>
<em></em>
<em>PS: </em>
These examples and explanations are given using <em>Java</em>. Similar scenario, maybe different syntax, will be obtainable in other programming languages.