Basic C++ Operations & Examples

Posted By: Java Examples - 10:10 PM


& Comment

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

+                                               Addition, also called unary addition

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

Example C++ Source code :

using namespace std;

int addition(int x,int y)

int subtraction(int x,int y)

int multiplication(int x,int y)

int division(int x,int y)

void main()
int x,y;
cout<<"Enter the two number"<

cout<<"X+Y equals : "<
cout<<"X-Y equals : "<<<
cout<<"X*Y equals : "<
cout<<"X/Y equals : "<
cout<<"Done! By"<


Output of this program :

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

About Java Examples

I’m passionate about Web Development and Programming and I go to extreme efforts to meet my passion. I’m a believer of learning the fundamentals first. I try to understand everything little bit more than the average.


Post a Comment

Copyright © 2016 C++ Examples ACHCHUTHAN.ORG. Designed by Templateism .