operators (1)

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

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

View Full Document Right Arrow Icon
1 Operators And Expressions
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Operators Arithmetic Operators Relational and Logical Operators Special Operators
Background image of page 2
3 Arithmetic Operators Operator Action Subtraction, also unary minus + Addition * Multiplication / Division % Modulus -- Decrement ++ Increment
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Precedence and Associativity Arithmetic Operators: High ++ -- - (unary minus) * / % Low + - - a * b – c ((- a) * b) – c
Background image of page 4
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
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 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
Background image of page 6
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).
Background image of page 7

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

View Full DocumentRight Arrow Icon
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 . “increment - then use”
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

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 Right Arrow Icon
Ask a homework question - tutors are online