Monday 13 July 2015

Arithmetic Operators :


Arithmetic operator is a symbol that performs mathematical operation on data. C++ provides many arithmetic operators. Following is a list of all arithmetic operators in C++.


OperationSymbolDescription
Addition+Adds two values
Subtraction-Subtracts one value from another value
Multiplication*Multiplies two values
Division/Divide one value by another value
Modulus%Gives the remainder of division of two integers


All arithmetic operators work with numeric values. Suppose we have two variables A and B where A = 10 and B = 5. Arithmetic operators can be used on A and B as follows :


OperationResult
A + B15
A - B5
A * B50
A / B2
A % B0


Some important points about modulus operator are as follows :

  • Modulus operator is also called remainder operator.
  • The modulus operator works only with integer values.
  • In expression like 3 % 5, 3 is not divisible by 5. Its result is 3.

No comments:

Post a Comment