Getting Familiar with Operators in C++


OPERATORS IN C++
Operators are special type of functions, that takes one or more arguments and produces a new value.
• For Example:  addition (+), subtraction (-), multiplication (*) etc,
Are all operators and operators are used to perform various operations on variables & constants.
Following are the types of Operators used in C++.
1.      Assignment Operator
2.      Arithmetic Operators
3.      Relational Operators
4.      Logical Operators
5.      Bitwise Operators
6.      Shift Operators
7.      Unary Operators
·         Assignment Operators
The Assignment Operator evaluates an expression on the right of the expression and substitutes it to the value or variable on the left of the expression.
·        Arithmetic Operators
All the basic arithmetic operations can be carried out in C++, these are operators used to perform basic mathematical operations. Addition (+) , subtraction (-) , diversion (/) multiplication (*) and modulus (%) are the basic mathematical operators. Modulus operator cannot be used with floating-point numbers.
·        Relational Operators
These operators establish a relationship between operands. The relational operators are : less than (<) , grater that  (>) , less than or equal to (<=), greater than equal to (>=), equivalent (==) and not equivalent (!=).

·        Logical Operators

The logical operators are AND (&&) and OR (||). They are used to combine two different expressions together.  If two statement are connected using AND operator, the validity of both statements will be considered, but if they are connected using OR operator, then either one of them must be valid.


·        Bitwise Operators

There are used to change individual bits into a number. They work with only integral data types like char, int and long and not with floating point values.

·        Shift Operators

Shift Operators are used to shift Bits of any variable. It is of three types,
1.      Left Shift Operator <<
2.      Right Shift Operator >>

·        Unary Operators


These are the operators which work on only one operand. There are many unary operators, but increment ++and decrement -- operators are most used., other examples are unary minus - and unary plus +.

No comments:

Post a Comment

Total Pageviews