## Introduction to Arithmetic Operators in C++

Arithmetic operators are used to performing some mathematical operations. Like any other operator, C++ also supports arithmetic operators to perform some mathematical actions like addition, subtraction, multiplication, etc. In this article, we are going to discuss those operators supported by the C++ language.

### Top 7 Arithmetic Operators in C++

Below is the list of different operators explained in more detail.

**Addition Operator (+)**: It is used to add two operands. Suppose X and Y are two operands, this plus operators will add up these two operands X + Y.**Subtraction Operator (-):**It is used to subtract two operands. Suppose X and Y are two operands, then this minis operator will subtract the value of the second operand from the first operand.**Multiplication Operator (*):**It is used to multiply two operands. Suppose X and Y are two operands then this multiplication operator will multiply X with Y.**Division Operator (/):**It is used to numerator by the denominator. Suppose X and Y are two operands, this division operator divides the numerator by denominator.**Modulus Operator (%):**It is used to give the remainder of the division. Suppose X and Y are two operands then this modulus operator first divides the numerator by denominator and gives the remainder.**Increment Operator (++):**It is used to increment the value of the variable by 1. Suppose X is the operand, then this increment operator will add the value of X by 1.**Decrement Operator (–):**It is used to decrementing the value of the variable by 1. Suppose X is the operand, this decrement operator will decrement the value of X by 1.

### Examples of Arithmetic Operators in C++

Let’s discuss some examples to understand them in a better way.

#### Example #1 – Program to Use Addition (+) Arithmetic Operator

**Code:**

`#include <iostream>`

using namespace std;

int main()

{

int X, Y, total;

cout << "Enter the value of X: ";

cin >> X;

cout << "Enter the value of Y: ";

cin >> Y;

total = X + Y;

cout << "Addition of X and Y is: " << total;

return 0;

}

**Output:**

#### Example #2 – Program to Use Subtraction (-) Arithmetic Operator

**Code:**

`#include <iostream>`

using namespace std;

int main()

{

int X, Y, subtract;

cout << "Enter the value of X: ";

cin >> X;

cout << "Enter the value of Y: ";

cin >> Y;

subtract = X - Y;

cout << "Subtraction of Y from X is: " << subtract;

return 0;

}

**Output:**

#### Example #3 – Program to Use Multiplication (*) Arithmetic Operator

**Code:**

`#include <iostream>`

using namespace std;

int main()

{

int X, Y, multiply;

cout << "Enter the value of X: ";

cin >> X;

cout << "Enter the value of Y: ";

cin >> Y;

multiply = X * Y;

cout << "Multiplication of X and Y is: " << multiply;

return 0;

}

4.5 (3,008 ratings)

View Course

**Output:**

#### Example #4 – Program to Use Division (/) Arithmetic Operator

**Code:**

`#include <iostream>`

using namespace std;

int main()

{

int X, Y, divide;

cout << "Enter the value of X: ";

cin >> X;

cout << "Enter the value of Y: ";

cin >> Y;

divide = X/Y;

cout << "Division of X and Y is: " << divide;

return 0;

}

**Output:**

#### Example #5 – Program to Use Modulus (%) Arithmetic Operator

**Code:**

`#include <iostream>`

using namespace std;

int main()

{

int X, Y, remainder;

cout << "Enter the value of X: ";

cin >> X;

cout << "Enter the value of Y: ";

cin >> Y;

remainder = X % Y;

cout << "Remainder of X and Y is: " << remainder;

return 0;

}

**Output:**

#### Example #6 – Program to Use Increment (++) Arithmetic Operator

**Code:**

`#include <iostream>`

using namespace std;

int main()

{

int X;

cout << "Enter the value of X: ";

cin >> X;

X++;

cout << "Incremented value of X: " << X;

return 0;

}

**Output:**

#### Example #7 – Program to Use Decrement (–) Arithmetic Operator

**Code:**

`#include <iostream>`

using namespace std;

int main()

{

int X;

cout << "Enter the value of X: ";

cin >> X;

X--;

cout << "Decremented value of X: " << X;

return 0;

}

**Output:**

### Recommended Articles

This is a guide to Arithmetic Operators in C++. Here we discuss the introduction and top 7 arithmetic operators in C++ along with examples and code implementation. You may also look at the following articles to learn more-