# Arithmetic Operators in C++  Written by Sagar RabidasFebruary 6, 2022
C++
1 VIEWS 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 1 VIEWS SHARE Sagar Rabidas

Software Developer

## Arithmetic Operators in C++

Mathematics operators are used to carrying out a few mathematical operations. Like some other operators, C++ additionally supports mathematics operators to carry out a few mathematical actions like addition, subtraction, multiplication, and so forth. In this newsletter, we are going to discuss the 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;`
`}`

### 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;`
`}`

### 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;`
`}`

### 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;`
`}`

### 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;`
`}`

### 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;`
`}`

### 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;`
`}`

C
C++
Arithmetic Operators
1 VIEWS 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 1 VIEWS SHARE     You must be Logged in to comment
Code Block Sagar Rabidas
Software Developer     +9 more
300 Blog Posts
Trending Technologies
15 Software40 DevOps48 Frontend Development24 Backend Development20 Server Administration17 Linux Administration26 Data Center24 Sentry24 Terraform23 Ansible83 Docker70 Penetration Testing16 Kubernetes21 NGINX20 JenkinsX17
Recommended Blogs
8        8 Anik Adhikary Anik Adhikary Anik Adhikary Anik Adhikary Anik Adhikary Anik Adhikary Anik Adhikary Anik Adhikary Techiio is on the journey to build an ocean of technical knowledge, scouring the emerging stars in process and proffering them to the corporate world.