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

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

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

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

View Full Document
Eg: x < 10 The result of a relational expression is a boolean value (true or false) Logical Operators Operator Meaning AND conditional AND | OR
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
Ask a homework question - tutors are online