write a short note on operaters and operands
Answers
Operator and operand examples. + and * are arithmetic operators while the symbols appearing on either side of them are operands. Constants, variables, and function return values may all serve as operands and may be intermixed when forming expressions.
- Operands may be constants
- Operands may be variables
- Operands may be more complex expressions; in this example, 2, A, 5, and B are * operands while 2 * A and 5 * B are + operands
- The value returned by a non-void function may also serve as an operand
Unary Operators
Unary operators only require one operand. Most of the time the operand is placed to the right of the operator but sometimes it is placed to the left. The most common example is the unary minus: ‑N, which changes the sign of the value stored in variable N.
Binary Operators
Binary operators require two operands. The arithmetic operators are the most familiar examples of binary operators. The assignment operator is also common. For example:
A = counter + 5;
"counter" and "5" are the "+" operator's operands, and "A" and the value of the expression "counter + 5" are the "=" operator's operands. Note that the above example ends with a semicolon, which also makes it an example of a statement (specifically, an assignment statement).
Ternary Operator
The single C++ ternary operator is the conditional operator, which is formed with two symbols and requires three operands:
op1 ? op2 : op3
The conditional operator is described in detail later in this chapter.
Operators categorized by the number of operands. We can easily categorize operands by the number of operands that they require.
Answer:
The operators indicate what action or operation to perform. The operands indicate what items to apply the action to.
hope it helps you