Home / code / cpp

C++ operators

Mathematical operators

+ add
- subtract
* multiply
/ divide
% rest of a dividing

Assignment operators

Assignment operator means the same as
variable += 1 variable= variable + 1
variable -= 1 variable= variable - 1
variable *= 1 variable= variable * 1
variable /= 1 variable= variable / 1
variable %= 1 variable= variable % 1

The increment operator (++)

variable++ variable += 1 variable = variable+ 1

You can write the ++ before or after the variable (prefix - postfix). If you use prefix in a calculation, the variable is first raised and then used in the calculation. With a postfix-operator, the variable is first used in the calculation and then raised.

Relational operators

Operator explanation
> Greater than
< smaller than
>= greater than or equal
< smaller than or equal
== equal
!= not equal

Logical operators

&& and
|| or
! not

 

TOP

Latest script:

 

Books: