Pages

Operator


Introduction  of  Operator: Operator  are the symbols that are used to perform the various operation on the operand .such as
                              
                                 A + b *  c
It can perform the various operation like arithmetic operations ,comparison or logical operations etc..it refer to a symbol that tells the computer to perfoem certain mathematical or logical tasks on operands .Operators can be unary and Binary .Unary operators work on onoperand like – a,b++ etc Binary operators work on the operators like a+b,  a*c…

Types of Operators:

1. Arithmetic Operators
2  Logical    Operators
3  Assignment  Operators
4  Relational  Operators
5  Bitwise Operators
6  Unary Operators
7  Sizeof ()  Operators
8 Conditional Operators
9  Comma Operators


Arithmetic Operators :This is used perform the arithmetic Operators on the operand such as +, * ,/ ,-,%
Name
Symbol in C
Addition
+
Subtraction
-
Multiplication
*
Division
/
Modulus
%

Arithmetic Operators are Classified in to 3 Categories
.Integer arithmetic
.Real   arithmetic
.Mixed mode arithmetic

Logical  Operators .It used when we want to test more than one condition to make decisions .The result of logical operator AND will be true only if both conditions are true and OR will be true if one or more conditions are true .
Name
Symbol
AND
&&
OR
||
NOT
!


Assignment Operators:--It is used to assign value to the variable .Value can be any constant Value or evalution of an Expression .eg
                                                           
a = 5;
Some Assignment Operator are given below :
Operator
Example
+=
X+=6
*=
A*=12
/=
a/=11
-=
z-=3
%=
Z%=2


Bitwise operator  These Operators are used for testing the bits and shift them into left and right .it manipulation of data at bit level
Operators
Meaning
>> 
Right Shift
<< 
Left Shift
^
XOR
|
OR
&
AND Bitwise

Relational Operators: this Operators are used to check the relation between two operands .These are use to compare the two different operand and then take decisions they compare such operand is greater ,less or equal of another operand  eg

                                              A > b

Name
Symbol
Greater than
> 
Less than
< 
Equal
==
Greater than equal
>=
Less than equal
<=
Not equal
!=


Increment /Decrement Operator : The Increment Operator increase the values of and operand by 1 and add the 1 value in current value and Decrement  decrease the value of and operand by 1 means subtract the 1 value from current value

1.      Increment (++)
2.      Decrement (--)


Sizeof () Operator: The Sizeof () Operator returns the size in bytes of the given operand .A Sizeof () Operator is a unary operator that returns  the number of bytes required to store a variable or a data type

Syntax  sizeof(data type of variable)
          
              Sizeof (int)

Comma  Operator : The comma Operator (,) is used to declare more than one variable in single line .it is also know as separator as it separates one variable name from other ..
                         
                                    int a,b,c;
Ternary Operator  This is also called a Conditional  operator .it is used the symbol  ?  and ' : ' .Ternary operator takes three statements ..

Syntax  :  <condition>?<expression1>:<expressioin2>

The conditon is evaluted first .if the result is true then expression 1 is executed ,otherwise expression 2 is executed 
eg..        if x=12,y=5
            a=(x>y)?x:y

0 comments: