Unit 3 Operators-1
Unit 3 Operators-1
1. Assignment Operators
Description: Used to assign values to variables.
2. Numeric Operators
Description: Used for mathematical calculations.
Postfix: The operator appears after the variable, e.g., x++, x--.
5. Bitwise Operators
Description: Operate on binary representations of numbers.
Examples: & (AND), | (OR), ^ (XOR), ~ (NOT), << (left shift), >> (right shift)
6. Logical Operators
Description: Used to perform logical operations.
7. Relational Operators
Description: Compare two values and return a boolean result.
Examples: == (equal to), != (not equal to), > (greater than), < (less than), >=
(greater than or equal to), <= (less than or equal to)
8. Short-Circuit Operators
Description: Logical operators that stop evaluating as soon as the result is
determined.
9. sizeof Operator
Description: Returns the size of a data type or object in bytes. Examples: sizeof(int)
might return 4.
Examples:
HOTS:
Explain how operator precedence and associativity affect the evaluation of the
expression 2 + 3 * 5.
Describe a scenario where short-circuit operators could be useful in
programming.
Compare and contrast implicit and explicit type conversion, providing examples
where each might be preferred.