e. Which of the following is a ternary operator?
(i) %
(ii) ? :
(iii) !
Answers
Answer:
In computer programming, ?: is a ternary operator that is part of the syntax for basic conditional expressions in several programming languages. It is commonly referred to as the conditional operator, inline if (iif), or ternary if. An expression a ? b : c evaluates to b if the value of a is true, and otherwise to c. One can read it aloud as "if a then b otherwise c".
It originally comes from CPL, in which equivalent syntax for e1 ? e2 : e3 was e1 → e2, e3.[1][2]
Although many ternary operators are possible, the conditional operator is so common, and other ternary operators so rare, that the conditional operator is commonly referred to as the ternary operator.
Hope it helps you
thanks
take care of yourself and your family
be at home be safe
Answer:
Option ii) ? : is the correct answer.
Explanation:
-A ternary operator is the one that takes 3 operands. Fr eg the ? : operator.
Let us look at an example.
x>y ? print ("x is greater) : print ("y is greater");
Here, the condition x>y is checked. If true, the statement after ? gets executed. Else, the statement after : gets executed.
-% is a binary modulus operator that returns the remainder after integer division. A binary operator takes 2 operands.
-! is a unary NOT operator. it is used to inverse the value. A unary operator takes 1 operand.
Hence, the answer is option ii) ? :