Operators in C

 

OPERATORS

 

  1. Arithmetic operators
  2. Relational operators
  3. Logical operators
  4. Assignment operator
  5. Increment and decrement operators
  6. Conditional operators
  7. Bitwise operators
  8. Comma operator
  9. sizeof operator

 

Arithmetic Operators

 

Operator

Meaning

+

Addition or unary plus

-

Subtraction or unary minus

*

Multiplication

/

Division

%

Modulo division or remainder after division

 

Relational Operators

 

Operator

Meaning

<

Less than

>

Greater than

<=

Less than or equal to

>=

Greater than or equal to

==

Equal to

!=

Not equal to

 

Logical Operators

 

Operator

Meaning

&&

Logical AND

||

Logical OR

!

Logical NOT

 

Assignment Operator

 

                        =,+=,-=,*=,/=,%=

 

Increment and Decrement Operators

                        ++,–

 

Conditional Operators

 

exp1 ? exp2 : exp3 ;

 


Bit wise Operators

 

Operator

Meaning

&

Bitwise AND

|

Bitwise OR

^

Bitwise XOR

<<

Shift left

>>

Shift right

~

One’s complement

 

EVALUATION OF EXPRESSIONS

 

Algebraic Expression

Equivalent C Expression

3.14x r2

3.14 * r * r

a

bc

a / (b * c)

5a2 + 3a + 1

5 * a * a + 3 * a + 1

s(s-a)(s-b)(s-c)

s * (s – a) * (s – b) * (s – c)

 

PRECEDENCE OF OPERATORS

 

Operator

Description

Associativity

Rank

()

[]

-> and .

Function call

Array element reference

Structure operators

Left to Right

1

+

-

++

!

~

*

&

sizeof

(type)

Unary plus

Unary minus

Increment

Decrement

Logical negation

One’s complement

Pointer reference (indirection)

Address

Size of an object

Type cast (conversion)

Right to left

2

*

/

%

Multiplication

Division

Modulus

Left to Right

3

+

-

Addition

Subtraction

Left to Right

4

<<

>>

Left shift

Right shift

Left to Right

5

<

<=

>

>=

Less than

Less than or equal to

Greater than

Greater than or equal to

Left to Right

6

==

!=

Equality

Inequality

Left to Right

7

&

Bitwise AND

Left to Right

8

^

Bitwise XOR

Left to Right

9

|

Bitwise OR

Left to Right

10

&&

Logical AND

Left to Right

11

||

Logical OR

Left to Right

12

?:

Condition expression

Right to left

13

=

*=

/=

%=

+=

-=

&=

^=

|=

<<=

>>=

Assignment operators

Right to left

14

,

Comma operator

Left to Right

15

 

 

 

 

 

Registration


A password will be e-mailed to you.

Feedback Form

Name (required)

Email (required)

Feedback