Operators in C Language

C Language provides a rich collection of operators. Here in this post we will see the operators supported in C-language, type of operators and precedence of operators

Operators in C

Operators use one or more operands to perform an action. Operators are symbols that inform to the computer to carry out operations with operands. The operations could be mathematical, logical or relational. C Language provides a rich set of operators.

Types of Operators in C

The Operators are categorized in the following on the basis of use.

  • Arithmetic operators
  • Relational operators
  • Logical operators
  • Unary operators
  • Conditional operator
  • Assignment operators
  • Bitwise operators
  • Other operators

Precedence of Operators in C

The Precedence of Operator determines order of the operators to be evaluated in an expression. Operations may be evaluated in two directions, left to right and right to left.

The table below illustrates the precedence of the operators and it’s direction of evaluation.

Group( ) [ ] Left to right
Postfix -> . Left to right
Postfix ++ — Left to right
Unary+ – ! ~ Right to Left
Prefix++ —Right to Left
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 to Left
Comma , Left to right

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *