C++ Operations & Examples

In any language, there are some operators to perform arithmetic, logical and control operations. The basic operators which are used to perform arithmetic operations on integers are as follows:

Operator                           Operation

-                                                Subtraction, also called unary subtraction

*                                                Multiplication

/                                                Division

%                                               Modulus (remainder after division)

++                                             Increment

--                                               Decrements

The operators +,-,* and / perform the same operation as they do in other languages. The operators + and – are unary operators and can take one or two operands. The multiply and divide are called binary operators as they take two operands.

Integer division will always give the result which is of integer type and truncates the remainder. The output of integer division will be the quotient. For example, 5/2 will give the answer 2 and not 2.5. The modulus operator gives the remainder after the integer division. For example, 5/2 will give the answer 1, which is the remainder. Here is a program which illustrates the functioning of the operators.

Output of this program :

Enter the two number
55
5
X+Y equals : 60
X-Y equals : 50
X*Y equals : 275
X/Y equals : 11
Done! By cpp.achchuthan.org
Press any key to continue . . .