operators in c
operators in c refers
to the symbols which are used to perform mathematical operations in c
programming. Operators are nothing but
the specific symbols which is used to perform mathematical operations in the
program.
Programming c is very rich
in operators. We can perform all type of mathematical operations in c. for that
it provides wide range of c operators.
C programming provides following type of different operators
 Arithmetic Operators
 Relational Operators
 Assignment Operators
 Logical Operators
 Increment and Decrement Operators
 Bitwise Operators
 Special Operators
C Arithmetic Operators
In c arithmetic operators are used to perform basic type of
mathematical operations such as addition,subtraction,multiplication ,division
etc. these operators are mostly use in the programs.
Following table shows the arithmetic operators and their use
with example.
Operator

Use

Example

+

Addition

2+2=4



Subtraction

22=0

*

Multiplication

2*2=4

/

Division

2/2=1

%

Reminder

2%2=0

C Relational Operators
Relational operators are used to check the relation between two operands.
relations such as less than,greater
than, equals to,etc. these operators are mostly used in decision making
statements.
operator

Use

Example

<

Returns true if value is smaller than
comparing value

4<2 returns false
2<8 returns true

>

Returns true if value is bigger than
comparing value

8>2 returns true
5>10 returns false

<=

Returns true if value is less or
equal to the given value

2<=5 returns true
6<=3 returns false
5<=5 returns true

>=

Returns true if value is greater or
equal to the given value

8>=8 returns true
5>=6 returns false
10>=6 returns true

==

Returns true if two values are same

10==10 returns true
6==5
returns false

!=

Returns true if given value is not
equal to comparing value

10!=10
returns false
10!=50 returns true

Assignment Operator
Assignment operators are used to assign values to the
variables. Following table shows the various assignment operators in c.
Operators

Example

equals

=

a = b

a = b

+=

a += b

a = a+b

=

a = b

a = ab

*=

a *= b

a = a*b

/=

a /= b

a = a/b

%=

a %= b

a = a%b

<<=

C <<= 2

is same as C = C
<< 2

>>=

C >>= 2

is same as C = C
>> 2

&=

C &= 2

is same as C = C
& 2

^=

. C ^= 2

is same as C = C ^ 2

=

C = 2

is same as C = C  2

Increment and decrement operators
Increment and decrement operators are used to increase and
decrease value of variables by 1 respectivly. following table shows details
about increment and decrement operators.
operator

Use

Example

++

Increase value of variable by one

a++



Decrease value of variables by one

a

Logical operators
Logical operators are used to check the conditions. It returns 0 or 1 depending upon condition become true
or false. Suppose a=0 and b=1
Operator

Description

Example

&&

It returns
true if given all conditions are become true

(a
&& b) is false.



It returns
true if any one condition becomes true

(a 
b) is true.

!

It converts
true to false and false to true

!(a
&& b) is true

Bitwise operator
Bitwise operators works on bit level. They perform
calculations on bit level. Following table shows the detail information about
bit level operators.
Operators

Meaning

&

Bitwise AND



Bitwise OR

^

Bitwise exclusive OR

~

Bitwise complement

<<

Shift left

>>

Shift right

specail operators
Following are some important operators which are very important in c. they are used for different purposes these operators shown in following table.
Operators

meaning

Example

sizeof()

Returns
the size of a variable.

sizeof(i),
where i is integer, will return 4.

&

Returns
the memory address of a variable.

&b;
returns the actual address of the variable.

*

Pointer
to a variable.

*b;

? :

Conditional
Expression.

If
Condition is true then it returns first value otherwise second value will be return
