Sei sulla pagina 1di 3

Different types of Operators in C

The symbols that give instructions to perform different types of mathematical and logical
operations are called operators. We can define operators as the tools which can alter the values
of data and variables. The important operators used in C language are:

 Arithmetic operators
 Logical operators
 Relational operators
 Assignment operators
 Conditional operators
 Increment or decrement operators
 Bit wise operators
 Special operators

Arithmetic operators
Arithmetic operators are commonly used operator in programming languages. C programming
language consists of Binary arithmetic and Unary arithmetic. The data, which is operated by
the operator, is called operand. In Unary operation there will be only one operand (eg: -1
Negative number). To perform a binary arithmetic, we need at least 2 operands. Different
arithmetic operators are given below:

Logical operators
Logical operators are also called Boolean operators. These operators are used to check two or
more conditions. Boolean operators are followed:
Relational operators
Operators used to compare two values according to their relation are called Relational
operators. These are also called Comparison operators. For performing relational operation we
must need two operands, then only we can illustrate and check the relation between them. 6
relational operators are:

Assignment operators
Assignment operators are used to assign a value to a variable. ‘=’ is used as assignment operator.
For example i=10;

Compound Assignment operators


These operators are used to assign a value to variable after getting a desired result.
For example x+=z;That is x=x+z;
Both of the above expressions have same meaning but first expression uses short hand
Compound assignment operator and second expression uses simple assignment operator. The
different compound operators are:

Conditional operators
These operators work according to some condition. The syntax is given by
i=expression1? Expression2:expression3
Eg: i=a>b?a:b;
The meaning of above statement is if a>b, then i=a, else i=b

Increment or Decrement operators


The powerful operators in C are increment and decrement operator. ‘++’ is used as increment
operator and ‘–’ used as decrement operator.
Eg: i++; meaning i=i+1;
i–; meaning i=i-1;

Bit wise operators


Bitwise operators are used to test the bit or to shift the bits to either left or right. Operators and
its use are given below:

Potrebbero piacerti anche