C Operators

C Tutorial

 C Operators (Complete Guide: Beginner → Advanced)

In C language, operators are special symbols that perform operations on variables and values.
They are used in calculations, conditions, logic, memory handling, and bit manipulation—making them fundamental for all C programs and interviews.


 What Are Operators in C?

Operators tell the compiler what operation to perform on operands (values or variables).


 Types of Operators in C

C operators are broadly divided into the following categories:

  1. Arithmetic Operators

  2. Relational Operators

  3. Logical Operators

  4. Assignment Operators

  5. Increment / Decrement Operators

  6. Bitwise Operators

  7. Conditional (Ternary) Operator

  8. Special Operators


 Arithmetic Operators

Used for mathematical calculations.

OperatorMeaning
+Addition
-Subtraction
*Multiplication
/Division
%Modulus (remainder)

Example

  • % works only with integers

 Relational Operators

Used to compare values (result is true/false).

OperatorMeaning
==Equal to
!=Not equal
>Greater than
<Less than
>=Greater or equal
<=Less or equal

 Logical Operators

Used to combine conditions.

OperatorMeaning
&&Logical AND
`
!Logical NOT
  •  Uses short-circuit evaluation

 Assignment Operators

Used to assign values.

OperatorMeaning
=Assign
+=Add & assign
-=Subtract & assign
*=Multiply & assign
/=Divide & assign
%=Modulus & assign

 Increment & Decrement Operators

OperatorMeaning
++Increment
--Decrement

Pre vs Post

  •  Very important for loops & interviews

Bitwise Operators (Advanced)

Operate on bits.

OperatorMeaning
&AND
``
^XOR
~NOT
<<Left shift
>>Right shift
  •  Used in embedded systems & low-level programming

 Conditional (Ternary) Operator

Syntax

Example

  •  Short form of if...else

 Special Operators

sizeof

Comma Operator

Address-of (&) and Dereference (*)


 Operator Precedence (Very Important)

Example:

  • * has higher precedence than
  •  Use parentheses () to avoid confusion.

 Common Mistakes

  •  Using = instead of ==
  •  Confusing logical (&&) and bitwise (&)
  •  Integer division mistakes
  •  Ignoring operator precedence

 Interview Questions (Must Prepare)

  1. Difference between = and ==

  2. Logical vs bitwise operators

  3. What is short-circuit evaluation?

  4. Pre vs post increment

  5. What does sizeof return?

  6. Operator precedence example


 Real-Life Use Cases

  • Calculations & analytics

  • Conditions & validations

  • Loop control

  • Bit manipulation (embedded)

  • Memory access (pointers)


 Summary

  •  Operators perform actions on data
  •  C has 8 major categories of operators
  •  Logical & relational operators control flow
  •  Bitwise operators work at bit level
  •  Crucial for DSA, system programming & interviews

You may also like...