Lecture 5 - Compound Assignment Operators General form var...

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

View Full Document Right Arrow Icon
Compound Assignment Operators General form: var operator(op)= expression; o Is equivalent to: var = var op expression; Eg: o x += 5; // x = x + 5 o z *= 3; // z = z * 3; o y /= a + b; // y = y / (a + b); Increment and Decrement Operators Can only be applied to integer data types x++ or ++x is the same as x = x+1 x-- or --x is the same as x = x – 1 A pre-increment operation is done before other operations in the expression (Increment FIRST, then the rest of the operation) o Eg: x = 10; y = ++x; // y = 11, x = 11 A post-increment operation is done after other operations in the expression (Increment AFTER doing the operation) o Eg: x = 10; y = x++; // y = 10, x = 11 Relational Operators Operator Meaning > greater than >= greater than or equal to < less than <= less than or equal to == equal to != not equal to
Background image of page 1

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

View Full Document Right Arrow Icon
Eg: x < 10 The result of a relational expression is a boolean value (true or false) Logical Operators Operator Meaning AND conditional AND | OR
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 4

Lecture 5 - Compound Assignment Operators General form var...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online