Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
38 views

Precedence of Operators in C

Operators are symbols that are used to perform operations in C like arithmetic, logical, and bitwise. There are different types of operators including arithmetic, relational, shift, logical, bitwise, ternary, assignment, and misc. The precedence and associativity of operators determines the order of evaluation, with * and / evaluated before + and -, and multiplicative operators evaluated before additive operators.

Uploaded by

Veena Parthan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Precedence of Operators in C

Operators are symbols that are used to perform operations in C like arithmetic, logical, and bitwise. There are different types of operators including arithmetic, relational, shift, logical, bitwise, ternary, assignment, and misc. The precedence and associativity of operators determines the order of evaluation, with * and / evaluated before + and -, and multiplicative operators evaluated before additive operators.

Uploaded by

Veena Parthan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

C Operators

An operator is simply a symbol that is used to perform operations. There can be many types
of operations like arithmetic, logical, bitwise etc.

There are following types of operators to perform different types of operations in C


language.

Arithmetic Operators
Relational Operators
Shift Operators
Logical Operators
Bitwise Operators
Ternary or Conditional Operators
Assignment Operator
Misc Operator

Precedence of Operators in C
The precedence of operator species that which operator will be evaluated first and next. The
associativity specifies the operators direction to be evaluated, it may be left to right or right
to left.

Let's understand the precedence by the example given below:

1. int value=10+20*10;

The value variable will contain 210 because * (multiplicative operator) is evaluated before
+ (additive operator).

The precedence and associativity of C operators is given below:

Category Operator Associativity

Postfix () [] -> . ++ - - Left to


right

Unary + - ! ~ ++ - - (type)* & sizeof Right to


left
Multiplicative */% Left to
right

Additive +- Left to
right

Shift << >> Left to


right

Relational < <= > >= Left to


right

Equality == != Left to
right

Bitwise AND & Left to


right

Bitwise XOR ^ Left to


right

Bitwise OR | Left to
right

Logical AND && Left to


right

Logical OR || Left to
right

Conditional ?: Right to
left

Assignment = += -= *= /= %=>>= <<= &= Right


^= |=

You might also like