C++ programming language provides us with various types of operators for performing different tasks. One such class of operators is arithmetic operators.

These are used for performing arithmetic calculations in a program.

Following is a list of the C++ arithmetic operators:

- Addition operator: ‘ + ‘
- Subtraction operator: ‘ – ‘
- Multiplication Operator: ‘ * ‘
- Division Operator: ‘/ ‘
- Modulus Operator: ‘ % ‘

Out of these five, you must be familiar with the first four operators. All these operators take two operands or i.e. they are binary operators. They work both with integers and floating point numbers in C++.

Along with these four, C++ uses an additional operator called the modulus or remainder operator represented using ‘ % ‘.

This operator is also a binary operator. But it works only with integers. It gives out the remainder when one number is divided by the other.

For example: 8 % 6 = 2 and 9 % 10 = 9.

The following C++ program illustrates the use of these operators.

//ChewCode program showing various arithmetic operators used in C++ #include<iostream> #include<conio.h> using namespace std; int main() { int a, b ; cout << "Enter two integers a and b : \n\n" ; cin >> a >> b; cout << "\nSum is " << a + b << "\n\n" ; cout << "Difference is " << a - b << "\n\n" ; cout << "Product is " << a * b << "\n\n" ; cout << "Quotient is " << a / b << "\n\n" ; cout << "Remainder is " << a % b << "\n\n" ; getch(); return 0; }

You may also store the results in separate variables. For example:

int c ; c = a + b ; cout << "Sum is " << c ;

NOTE: Do not use modulus operator with floats else compiler will generate an error. As mentioned earlier, it works only with integers. Other operators (+ , – , * , / ) work correctly with floating point numbers.

Here is a live preview of the program and its output.