C++ Arithmetic Operations

We can perform Arithmetic Operations in C++ on numbers using C++ Arithmetic Operators.

In this tutorial, we will learn about the list of Arithmetic Operators available in C++ programming language. We will also learn how to perform Arithmetic Operations, with the help of examples.

C+ Arithmetic Operators

OperatorNameExampleDescription
+Additiona + bReturns sum of a and b.
Subtractiona – bReturns difference of b from a.
*Multiplicationa * bReturns product of a and b.
/Divisiona / bReturns the quotient when a is divided by b.
%Modular Divisiona % bReturns reminder when a is divided by b.
++Incrementa++ or ++aIncrements the value of a by one.
Decrementa– or –aDecrements the value of a by one.

C++ Addition

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

C++ Program

#include <iostream>  
using namespace std;

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

   int sum = a + b;

   cout << sum << endl;
}

Output

19

Learn more about C++ Addition.

C++ Subtraction

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

C++ Program

#include <iostream>  
using namespace std;

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

   int diff = a - b;

   cout << diff << endl;
}

Output

5

Learn more about C++ Subtraction.

C++ Multiplication

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

C++ Program

#include <iostream>  
using namespace std;

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

   int product = a * b;

   cout << product << endl;
}

Output

84

Learn more about C++ Multiplication.

C++ Division

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

C++ Program

#include <iostream>  
using namespace std;

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

   int div = a / b;

   cout << div << endl;
}

Output

2

Learn more about C++ Division.

C++ Modular Division

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

C++ Program

#include <iostream>
using namespace std;

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

   int modulo = a%b;

   cout << modulo;
}

Output

3

Learn more about C++ Modular Division.

C++ Increment

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

C++ Program

#include <iostream>  
using namespace std;

int main() {
   int a = 12;
   ++a;
   cout << a << endl;
}

Output

13

Learn more about C++ Increment.

C++ Decrement

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

C++ Program

#include <iostream>  
using namespace std;

int main() {
   int a = 12;
   --a;
   cout << a << endl;
}

Output

11

Learn more about C++ Decrement.

Conclusion

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