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.
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;
}