What is a ternary operator? code example
Example 1: ternary operator
(condition) ? (if true, do this) : (otherwise, do this)
Example 2: Ternary Operator
condition ? expression-if-true : expression-if-false;
function findGreater(a, b) {
return a > b ? "a is greater" : "b is greater";
}
Example 3: one line conditional statement in c
str = arraeck(a, n) ? "YES" : "NO";
printf(arraeck(a, n) ? "YES" : "NO");