M3S2 Part 3 Flashcards
the symbols that tell the compiler to perform specific
mathematical or logical manipulations.
Operators
Types of Operators
- Assignment Operator
- Arithmetic Operators
- Compound Operators
- Relational Operators
- Logical Operators
a single equal sign (=) which
means that the value on the right side of the assignment expression
after the equal sign is assigned to the variable on the left.
assignment operator
specifies the
order of operations in expressions
that contain more than one operator.
Operator precedence
compound operators:
+= , -= , *= , /=, %=
y+= x; is equivalent to?
y = y+x
++ adds 1 to its operand
increment operator
– subtracts 1 from its operand.
decrement operator
Both the increment and decrement operators can either
precede
(prefix) or follow (postfix) the operand.
operators that allow the comparison of two or more numerical values, yielding a result based on whatever the comparison is true(1) or false(0).
relational operators
These operators are used to combine two or more conditions or to complement the evaluation of the original condition in consideration.
logical operators
The
result of the operation of a
logical operator is a
boolean
value either true or false
If both the operators are non-zero, then condition becomes true.
&& Logical AND operator
If any of the two operands is non-zero, then the condition becomes true
Logical OR Operator. ||
Use to reverses the logical state of its operand. If a condition is true, then this operator will make false
! Logical NOT Operator
works on bits and perform bit-by-bit operation.
Bitwise operator
Bitwise inclusive OR
OR |
Bitwise exclusive OR
XOR ^
Unary complement (bit inversion)
NOT ~
Shift bits left
«_space;SHL
Shift bits right
> > SHR
copies a bit to the
result if it exists in both operands.
Binary AND Operator &
copies a bit if it
exists in either operand.
Binary OR Operator |
copies the bit if it is
set in one operand but not both.
^ Binary XOR Operator
is
unary and has the effect of ‘flipping’ bits.
Binary Ones Complement Operator ~
he left
operands value is moved left by the
number of bits specified by the right
operand.
he left
operands value is moved left by the
number of bits specified by the right
operand.
The left
operands value is moved right by the
number of bits specified by the right
operand.
Binary Right Shift Operator >
are used to
construct conditional
expressions.
The conditional operators
? and :
Conditional operators are
also called as
ternary
operators.