Lesson 4 C++ Operators Flashcards
An _______ is a symbol that tells the
compiler to perform specific mathematical or
logical manipulations.
operator
What is the symbol for Assignment Operator
=
used for assignment, it takes the right-hand side (called rvalue) and copy it into the left-hand side (called lvalue).
’ = ‘
___________________________ modify the current value of a variable by performing an operation on it. Example. (+=, -=, *=, /=, %=,»_space;=, «=, &=, ^=, |=)
Compound assignment operators
There are operators used to perform basic
mathematical operations. Addition (+) , subtraction (-) , division (/) multiplication (*) and modulus (%) are the basic mathematical
operators.
Mathematical / Arithmetic Operators
increases the value of a variable by 1.
increment operator or ++
decreases the value of a variable by 1.
decrement operator or –
Two expressions can be compared using
relational and equality operators.
Ex. (==, !=, > , < , >=, <= )
Relational and Comparison Operators
Identify the operator for these description:
1.) Equal to
2.) Not equal to
3.) less than
4.) greater than
5.) less than equal to
6.) greater than or equal to
1.) ==
2.) !=
3.) <
4.) >
5.) <=
6.) >=
What are the Logical Operators
(!, && , ||)
What is the C++ operator for the
Boolean operation NOT.
!
This operator corresponds to the Boolean
logical operation AND
which yields true if both its operands are true, and false otherwise.
&&
This operator corresponds to the
Boolean logical operation OR
which yields true if either of its operands is true, thus being false only when both operands are false.
||
used to separate two or more expressions that are included where only one expression is expected. When the set of expressions has to be evaluated for a value, only the right- most
expression is considered.
comma operator (,)
evaluates an expression, returning one value if that expression evaluates to true, and a different one if the expression evaluates as false.
Symbol is “ ? “
Conditional Ternary Operator