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.

  1. C Assignment Operators
  2. C Arithmetic Operators
  3. C Logical Operators
  4. C Comparison Operators
  5. C Bitwise Operators

The following are miscellaneous operators.

  1. 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.

1. 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.

  1. C Assignment Operator
  2. C Addition Assignment Operator
  3. C Subtraction Assignment Operator
  4. C Multiplication Assignment Operator
  5. C Division Assignment Operator
  6. C Remainder Assignment Operator
  7. C Bitwise AND Assignment Operator
  8. C Bitwise OR Assignment Operator
  9. C Bitwise XOR Assignment Operator
  10. C Left-shift Assignment Operator
  11. C Right-shift Assignment Operator

2. 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.

  1. C Addition
  2. C Subtraction
  3. C Multiplication
  4. C Division
  5. C Modulus
  6. C Increment
  7. C Decrement

3. 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.

  1. C AND
  2. C OR
  3. C NOT

4. Comparison Operators

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

Operator NameOperator 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 Comparison Operators.

  1. C Equal-To Operator
  2. C Not-Equal Operator
  3. C Greater-Than Operator
  4. C Less-Than Operator
  5. C Greater-Than or Equal-To Operator
  6. C Less-Than or Equal-To Operator

5. 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 Bitwise Operators.

  1. C Bitwise AND Operator
  2. C Bitwise OR Operator
  3. C Bitwise XOR Operator
  4. C Bitwise Complement Operator
  5. C Bitwise Left Shift Operator
  6. C Bitwise Right Shift Operator