Followers

Tuesday, December 4, 2007

OPERATORS AND EXPRESSIONS IN C++

The operations ( specific tasks ) are represented by Operators and the objects of the operation(s) are referred to as Operands.

There are different types of operators.


Click here to see a pictorical representation of types of operators:

http://freemindshare.com/map/GTZ4nyQCUJ/

1. Arithmetic Operators:

to do arithmetic operations.

+, -, *, /, % are arithmetic operators.

Example: 6+7=13, 12%5=2.

There are 2 types of Arithemetic Operators:

a) Unary Operators

operators that act on one operand.


+, -, are unary operators.


Example:


if x=12 then +x=12 and -x = -12


if x= -12 then + x = - 12 and - x= 12



b) Binary Operators


operators that act on two operands.


*, /, %, -


Example:


if a= 2 and b=5 hten


a+b=7


a*b=10


b-a= 3


b%a=1


5 - ( - 4)= 9



2. Increment and Decrement Operators

C++ includes two useful operators not generally found in other computer languages except C.


++ adds 1 to its operand


-- subtracts 1 to its operand


These operators come in two varieties: Postfix and Prefix version


3. Relational Operators


4. Logical Operators


5. Conditional Operators


6. Some other Operators
... to be completed

No comments: