As studied earlier, Operators are the symbols, which performs operations on various data items known as operands. For Example: in a a+b
, a
and b
are operands and +
is an operator.
Note:- To perform an operation, operators and operands are combined together forming an expression. For example, to perform an addition operation on operands a and b, the addition(+) operator is combined with the operands a and b forming an expression.
The conditional operators are also called ternary operators. A conditional operators forms an expression that will have one of two values, depending on the truth value of another expression.
The expression can be written in place of an if-else statement. A conditional expression is written in the form expression1 ? expression2:expression3 When evaluating a conditional expression, expression1 is evaluated first.
If expression1 is tru(i.e., if its value is nonzero), then expression2 is evaluated and this becomes the value of the conditional expression.
Enter a signed numbe Absolute value = 22 Enter a signed number:23 Absolute value = 23