Beginner
minutes
Operators Terminology
Overview of operator concepts and terminology in this chapter.
Last updated:
This reference provides an overview of operator terminology you'll encounter in this chapter. Use it as a quick lookup guide.
Operator Basics
| Term | Definition | Example |
|---|---|---|
| Operator | Symbol that performs an operation on operands | +, -, *, /, % |
| Operand | Value that an operator acts upon | In a + b, both a and b are operands |
| Unary operator | Operator that takes one operand | -x, !flag, ++i |
| Binary operator | Operator that takes two operands | a + b, x * y |
| Ternary operator | Operator that takes three operands | condition ? a : b |
| Expression | Combination of operators and operands | (a + b) * c |
Precedence & Associativity
| Term | Definition | Example |
|---|---|---|
| Precedence | Order in which operators are evaluated | * before + in a + b * c |
| Associativity | Direction of evaluation for same precedence | Left-to-right: a - b - c |
| Left-to-right | Evaluate leftmost operator first | a / b / c = (a / b) / c |
| Right-to-left | Evaluate rightmost operator first | a = b = c = a = (b = c) |
| Parentheses | Override default precedence | (a + b) * c |
Arithmetic Operators
| Term | Definition | Example |
|---|---|---|
| Addition | Adds two values | a + b |
| Subtraction | Subtracts second from first | a - b |
| Multiplication | Multiplies two values | a * b |
| Division | Divides first by second | a / b |
| Modulo/Remainder | Remainder after division | a % b (7 % 3 = 1) |
| Integer division | Division truncating decimal | 7 / 3 = 2 |
| Floating-point division | Division preserving decimal | 7.0 / 3.0 = 2.333... |
Increment & Decrement
| Term | Definition | Example |
|---|---|---|
| Prefix increment | Increment before using value | ++x (increment, then use) |
| Postfix increment | Increment after using value | x++ (use, then increment) |
| Prefix decrement | Decrement before using value | --x |
| Postfix decrement | Decrement after using value | x-- |
| Side effect | Change to state beyond return value | x++ modifies x |
Comparison Operators
| Term | Definition | Example |
|---|---|---|
| Equality | Tests if two values are equal | a == b |
| Inequality | Tests if two values are not equal | a != b |
| Less than | Tests if first is smaller | a < b |
| Greater than | Tests if first is larger | a > b |
| Less than or equal | Tests if first is smaller or equal | a <= b |
| Greater than or equal | Tests if first is larger or equal | a >= b |
| Relational operator | Operators comparing two values | <, >, <=, >= |
Logical Operators
| Term | Definition | Example |
|---|---|---|
| Logical AND | True if both operands are true | a && b |
| Logical OR | True if either operand is true | a || b |
| Logical NOT | Inverts boolean value | !a |
| Short-circuit evaluation | Skipping unnecessary evaluation | false && f() skips f() |
| De Morgan's Laws | Rules for negating AND/OR | !(a && b) = !a || !b |
Other Operators
| Term | Definition | Example |
|---|---|---|
| Conditional operator | Ternary if-else expression | x > 0 ? "positive" : "non-positive" |
| Comma operator | Evaluates left, returns right | (a = 1, b = 2) returns 2 |
| Assignment operator | Assigns value to variable | x = 5 |
| Compound assignment | Combines operation with assignment | x += 5 (same as x = x + 5) |
Floating-Point Comparison
| Term | Definition | Example |
|---|---|---|
| Epsilon | Small value for approximate comparison | std::abs(a - b) < epsilon |
| Relative comparison | Compare based on value magnitude | Scale epsilon by value size |
| Absolute comparison | Compare with fixed tolerance | std::abs(a - b) < 0.0001 |
| NaN | Not-a-Number (invalid result) | 0.0 / 0.0 |
| Infinity | Result of overflow or divide-by-zero | 1.0 / 0.0 |
Create an account to track your progress and access interactive exercises. Already have one? Sign in.
Operators Terminology - Quiz
Test your understanding of the lesson.
7 questions
10 minutes
60% to pass
Lesson Discussion
Share your thoughts and questions
💬
No comments yet. Be the first to share your thoughts!