Identifying an operator
In the expression 7 + 3, which term is the operator?
- +
- 7
- 3
- add
- ++
What is an operand?
Which statement best describes an operand in programming expressions?
- A value or variable that an operator acts on
- A symbol that performs an operation
- The final computed result of an expression
- A punctuation mark used to end a statement
- An operant
Operator precedence example
Given the expression x = 2 * 5 + 1, which part is evaluated first according to standard operator precedence rules?
- 2 * 5
- x = 2
- 5 + 1
- x = (2 * 5) + 1
- 2 * (5 + 1)
Unary vs binary
Which of the following is an example of a unary operator applied to a single operand?
- -n
- a - b
- x / y
- p + q + r
- n-
Parentheses influence
In the expression (2 + 3) * 4, which part is evaluated first and why?
- 2 + 3 because parentheses override normal precedence
- 3 * 4 because multiplication has the highest precedence
- 2 * 3 because expressions are read strictly left to right
- 2 + (3 * 4) because addition always happens before multiplication
- 2 + 3 * 4 because parentheses are optional