In this tutorial, we will learn about different Arithmetic Operators available in C++ programming language and go through each of these Arithmetic Operators in detail, with the help of examples.

C++ Arithmetic Operators

Arithmetic Operators are used to perform common mathematical operations like addition, subtraction, multiplication, division, etc.

Tutorials

Arithmetic Operators

The following table specifies symbol, example, and description for each of the Arithmetic Operator in C++.

Arithmetic OperationOperator SymbolExampleDescription
Addition+a + bReturns sum of a and b.
Subtractiona – bReturns difference of b from a.
Multiplication*a * bReturns product of a and b.
Division/a / bReturns the quotient when a is divided by b.
Modular Division%a % bReturns reminder when a is divided by b.
Increment++a++ or ++aIncrements the value of a by one.
Decrementa– or –aDecrements the value of a by one.

Examples

C++ Addition

+ operator computes the addition of the two operands and returns the result.

main.cpp

</>
Copy
#include <iostream>
using namespace std;

int main() {
   int a = 12;
   int b = 7;

   int sum = a + b;

   cout << "Addition : " << sum << endl;
}

Output

Addition : 19
Program ended with exit code: 0

Learn more about C++ Addition.

C++ Subtraction

- operator computes the difference of right operand from left operand and returns the result.

main.cpp

</>
Copy
#include <iostream>
using namespace std;

int main() {
   int a = 12;
   int b = 7;

   int diff = a - b;

   cout << "Subtraction : " << diff << endl;
}

Output

Subtraction : 5
Program ended with exit code: 0

Learn more about C++ Subtraction.

C++ Multiplication

* operator computes the product of two operands and returns the result.

main.cpp

</>
Copy
#include <iostream>
using namespace std;

int main() {
   int a = 12;
   int b = 7;

   int product = a * b;

   cout << "Multiplication : " << product << endl;
}

Output

Multiplication : 84
Program ended with exit code: 0

Learn more about C++ Multiplication.

C++ Division

+ operator computes the division of first operand with second operand and returns the quotient.

main.cpp

</>
Copy
#include <iostream>
using namespace std;

int main() {
   int a = 16;
   int b = 7;

   int div = a / b;

   cout << "Quotient : " << div << endl;
}

Output

Quotient : 2
Program ended with exit code: 0

Learn more about C++ Division.

C++ Modular Division

% operator computes the division of the given operands and returns the remainder.

main.cpp

</>
Copy
#include <iostream>
using namespace std;

int main() {
   int a = 13;
   int b = 5;

   int modulo = a%b;

   cout << "Remainder : " << modulo << endl;
}

Output

Remainder : 3
Program ended with exit code: 0

Learn more about C++ Modular Division.

C++ Increment

++ operator increments the value of the operand by one.

main.cpp

</>
Copy
#include <iostream>
using namespace std;

int main() {
   int a = 12;
   ++a;
   cout << "Incremented value : " << a << endl;
}

Output

Incremented value : 13
Program ended with exit code: 0

Learn more about C++ Increment.

C++ Decrement

++ operator decrements the value of the operand by one.

main.cpp

</>
Copy
#include <iostream>
using namespace std;

int main() {
   int a = 12;
   --a;
   cout << "Decremented value : " << a << endl;
}

Output

Decremented value : 11
Program ended with exit code: 0

Learn more about C++ Decrement.

Conclusion

In this C++ Tutorial, we learned what Arithmetic Operators are, and what they can do, with the help of example C++ programs.