Arithmetic Operators the symbols that are used to perform mathematical operations on operands such as addition, subtraction, multiplication, division etc.
operator | description |
---|---|
+ | addition adds two operands. eg, a+b. |
- | subtraction subtracts two operands. eg, a-b. |
* | multiplication multiplies two operands. eg, a*b. |
/ | division divides the operand by the second. eg, a/b. |
% | modulo returns the remainder when the first operand is divided by the second. For example, a%b. |
Example: C++ program for the Arithmetic operators.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #include <iostream> using namespace std; int main() { int a = 12; int b = 5; int result; result = a + b; cout << "Addition Result: " << result << endl; result = a - b; cout << "Subtraction Result: " << result << endl; result = a * b; cout << "Multiplication Result: " << result << endl; result = a / b; cout << "Division Result: " << result << endl; result = a % b; cout << "modulo Result: " << result << endl; return 0; } |
Output: Result of Arithmetic Operators in C++
1 2 3 4 5 | Addition Result: 17 Subtraction Result: 7 Multiplication Result: 60 Division Result: 2 modulo Result: 2 |