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 preincrement 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 postincrement 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.
 Fall '09
 Li
 Equals sign, relational operator, Decrement Operators, Operators Operator

Click to edit the document details