Skip to main content

Operators in C

An operator is a symbol that tells the compiler to perform a specific operation on one or more operands (variables or values).

Arithmetic Operators

Used to perform mathematical operations (assume a = 10, b = 3): / performs integer division when both operands are integers (drops the decimal). % gives the remainder of that division.

Assignment Operators

Assign values to variables. The right-hand side is evaluated first, then assigned to the left.
Chained assignment:
Compound assignment:

Relational Operators

Compare two values. Result is 1 (true) or 0 (false). Assume a = 10, b = 5:

Logical Operators

Combine multiple conditions:

Bitwise Operators

Operate at the binary (bit) level: Example:

Increment / Decrement Operators


Practice Programs

Problem 1: Sum, Difference, Product, Quotient, Remainder
Problem 2: Average of Three Numbers
Problem 3: Convert Days into Years, Weeks, Days
Problem 4: Check Even or Odd
Problem 5: Simple Interest Calculator