C Operators

C Operators are symbols that take one or two operands, perform a specific action on these operands, and returns the result.

Operators can be classified into following groups.

  • C Assignment Operators
  • C Arithmetic Operators
  • C Logical Operators
  • C Relational Operators
  • C Bitwise Operators
  • C Ternary Operator

In this tutorial, we shall go through each of these Operators, and also list out individual tutorials that describe respective operators in detail.

Assignment Operators

Arithmetic operators are used to perform common operations like addition, subtraction, multiplication, division, etc.

The following table specifies symbol, example, and description for each of the Assignment Operator in C programming.

Assignment
Operation
Operator SymbolExampleDescription
Simple Assignment=x = 2Assign x with 2.
Addition Assignment+=x += 3Add 3 to the value of x and assign the result to x.
Subtraction Assignment-=x -= 3Subtract 3 from x and assign the result to x.
Multiplication Assignment*=x *= 3Multiply x with 3 and assign the result to x.
Division Assignment/=x /= 3Divide x with 3 and assign the quotient to x.
Remainder Assignment%=x %= 3Divide x with 3 and assign the remainder to x.
Bitwise AND Assignment&=x &= 3Perform x & 3 and assign the result to x.
Bitwise OR Assignment|=x |= 3Perform x | 3 and assign the result to x.
Bitwise-exclusive-OR Assignment^=x ^= 3Perform x ^ 3 and assign the result to x.
Left-shift Assignment<<=x <<= 3Left-shift the value of x by 3 places and assign the result to x.
Right-shift Assignment>>=x >>= 3Right-shift the value of x by 3 places and assign the result to x.

The following are the list of detailed tutorials for Arithmetic Operators.

  • C Simple Assignment Operator
  • C Addition Assignment Operator
  • C Subtraction Assignment Operator
  • C Multiplication Assignment Operator
  • C Division Assignment Operator
  • C Remainder Assignment Operator
  • C Bitwise AND Assignment Operator
  • C Bitwise OR Assignment Operator
  • C Bitwise XOR Assignment Operator
  • C Left-shift Assignment Operator
  • C Right-shift Assignment Operator

Arithmetic Operators

Arithmetic operators are used to perform common operations like addition, subtraction, multiplication, division, etc.

Arithmetic OperationOperator SymbolExampleDescription
Addition+a + bReturns sum of a and b.
Subtractiona – bReturns difference of b from a.
Multiplication*a * bReturns product of a and b.
Division/a / bReturns the quotient when a is divided by b.
Modular Division%a % bReturns reminder when a is divided by b.
Increment++a++ or ++aIncrements the value of a by one.
Decrementa– or –aDecrements the value of a by one.

The following are the list of detailed tutorials for Arithmetic Operators.

Logical Operators

Logical operators are used to perform boolean operations like AND, OR, and NOT.

Logical OperationOperator SymbolExampleDescription
AND&&x && yReturns AND between x and y.
OR||x || yReturns OR between x and y.
NOT!!x Returns negation of x.

The following are the list of detailed tutorials for Logical Operators.

Relational Operators

Relational operators are used to compare given values. These are also called Comparison Operators.

Relational OperationOperator SymbolExampleDescription
Equal To==x == yReturns true if x is equal to y, else it returns false.
Not Equal!=x != yReturns true if x is not equal to y, else it returns false.
Greater Than>x > yReturns true if x is greater than y, else it returns false.
Less Than<x < yReturns true if x is less than y, else it returns false.
Greater Than or Equal To>=x >= yReturns true if x is greater than or equal to y, else it returns false.
Less Than or Equal To<=x <= yReturns true if x is less than or equal to y, else it returns false.

The following are the list of detailed tutorials for Logical Operators.

  • C Equal To Operator
  • C Not Equal Operator
  • C Greater Than Operator
  • C Less Than Operator
  • C Greater Than or Equal To Operator
  • C Less Than or Equal To Operator

Bitwise Operators

C Bitwise Operators are used to perform bitwise operations on integer or char operands. Bitwise operations are done at bit level, meaning, operations like AND, OR, XOR, etc., are done between respective bits of the operands.

The following table specifies symbol, example, and description for each of the Bitwise Operator in C programming.

Bitwise OperationOperator SymbolExampleDescription
AND&x & yReturns the bitwise AND operation between x and y.
OR|x | yReturns the bitwise OR operation between x and y.
XOR^x ^ yReturns the bitwise XOR operation between x and y.
Complement~~xReturns the complement of x.
Left Shift<<x << yReturns the result of x left shifted by y number of places.
Right Shift>>x >> yReturns the result of x right shifted by y number of places.

The following are the list of detailed tutorials for Logical Operators.

  • C Bitwise AND Operator
  • C Bitwise OR Operator
  • C Bitwise XOR Operator
  • C Bitwise Complement Operator
  • C Bitwise Left Shift Operator
  • C Bitwise Right Shift Operator

Conclusion

In this C Tutorial, we learned about different types of operators in C programming.