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:

  1. Addition operator:  ‘ + ‘
  2. Subtraction operator:  ‘ – ‘
  3. Multiplication Operator: ‘ * ‘
  4. Division Operator: ‘/ ‘
  5. 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.

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

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.

Various Arithmetic Operators used in C++

Drop your queries below.


Founder & Senior Editor of ChewCode.com and Editor at GizmoBolt.com. Sakshi is currently pursuing MCA. She is a foodie and has a unique love for learning computer programming languages. Follow her on Google + | Facebook | Twitter. Contact her at [email protected] for feedback and sending tips.

Tags: , , , , , , ,

Leave A Response