Written by **Sagar Rabidas**February 6, 2022

7 min read

C++

Software Developer

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.

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.

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

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

}

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

}

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

}

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

}

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

}

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

}

#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

Was this blog helpful?

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

Recommended Threads

8

Anik Adhikary

Anik Adhikary

Anik Adhikary