Arithmetic operators ( +, -, , , % )
The five arithmetical operations supported by the C++ language are:
+ addition
- subtraction
* multiplication
/ division
% modulo
Operations of addition, subtraction, multiplication and division literally correspond with their respective
mathematical operators. The only one that you might not be so used to see is modulo; whose operator is the
percentage sign (%). Modulo is the operation that gives the remainder of a division of two values. For example, if
we write:
a = 11 % 3;
the variable a will contain the value 2, since 2 is the remainder from dividing 11 between 3.
The five arithmetical operations supported by the C++ language are:
+ addition
- subtraction
* multiplication
/ division
% modulo
Operations of addition, subtraction, multiplication and division literally correspond with their respective
mathematical operators. The only one that you might not be so used to see is modulo; whose operator is the
percentage sign (%). Modulo is the operation that gives the remainder of a division of two values. For example, if
we write:
a = 11 % 3;
the variable a will contain the value 2, since 2 is the remainder from dividing 11 between 3.
Learn More :
Operators
- Operating with variables in C++
- Assignment operator (=) in C++
- Increase and decrease (++, --) operators in C++
- Relational and equality operators ( ==, !=, >, <, >=, <= ) in C++
- Logical operators ( !, &&, || ) in C++
- Conditional operator ( ? ) in C++
- Comma operator ( , ) in C++
- Bitwise Operators ( &, |, ^, ~, <<, >> )
- Precedence of Operators in C++