...............Operators work with single operands?
Ternary
Binary
Unary
None of These
I
Answers
Answer:
Unary operators need only one operand to perform the task or operation.
e.g +, -, ++, -- etc
Here + & - operators will indicate the sign of operand. (e.g +5, -3, -45 )
The ++ & -- operators are called increament & decreament operators respectively.
The ++ operator will increase the value of operand by one & -- operator will decrease the value of operand by one. (e.g x++ or ++x = x+1 & x-- or --x = x-1)
Binary operators
Binary operators required two operands to perform the operation.
e.g +, -, *, /, % etc
Here these + & - operators will not indicate the sign of operand but add or substract two operands, because these are binary operators(e.g 3+5, 3–5)
Ternary operators
Ternary operators required three operands to perform the operation.
e.g ? & :
These are also called conditional operators.
Syntax is as
condition?expression1:expression2;
If condition is true expression1 will be executed otherwise expression2 will be executed. (e.g 3>2?T:F).
Unary operators work with a single operand.
- Only one operand is necessary for unary operators; they perform different operations such as increasing or decreasing value by one.
- It also negates an expression, or reversing a boolean 's value.
- It is possible to add increment as well as a decrement operator before the prefix or after the postfix in an operand.