{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

operators (1)

# operators (1) - Operators And Expressions 1 Operators...

This preview shows pages 1–9. Sign up to view the full content.

1 Operators And Expressions

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 Operators Arithmetic Operators Relational and Logical Operators Special Operators
3 Arithmetic Operators Operator Action Subtraction, also unary minus + Addition * Multiplication / Division % Modulus -- Decrement ++ Increment

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
4 Precedence and Associativity Arithmetic Operators: High ++ -- - (unary minus) * / % Low + - - a * b – c ((- a) * b) – c
5 Expressions inside parentheses inside parentheses are evaluated first. 1 * (2 - 3) Operators on the same level of precedence are evaluated from left to right . ( Associativity ). 1 + 2 + 3 + 4 –5 (((1 + 2) + 3) + 4) –5

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
6 Increment & Decrement Operators Provide a concise notation for incrementing or decrementing a variable by 1. Are unary operators. ++x or x++ --x or x-- Can be applied to variables but not to constants or ordinary expressions. ++i; legal cnt--; legal 777++; illegal ++(a * b -1); illegal
7 May either prefix or postfix the operand. Prefix ++x; or Postfix x++; x = x + 1; ++ & -- both cause a value of a variable to change in memory. ( Have a side effect).

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
8 Increment Postfix : i++; Expression value is the current value (Before you increment ) then it increments. “use - then increment” Increment Prefix : ++i; Expression value is the value After you increment .
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 34

operators (1) - Operators And Expressions 1 Operators...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online