Thuta Learning
BasicProgrammingbeginner

Operators

Relax. We'll talk through this in plain words — no textbook voice.

Operators are symbols used to calculate values, compare them, and make logical decisions. Arithmetic operators handle math calculations, comparison operators check conditions, and logical operators are useful for combining multiple conditions.

c
#include <stdio.h>

int main() {
  int x = 10;
  int y = 3;

  printf("Add: %d
", x + y);
  printf("Remainder: %d
", x % y);
  printf("Is x greater than y? %d", x > y);
  return 0;
}

+ adds, % gives the remainder, and x > y checks whether a condition is true. In C, true shows up as 1 and false as 0.

You should see
Add: 13 Remainder: 1 Is x greater than y? 1

Info

= assigns a value, while == compares for equality. These two are not the same — don't mix them up.

Easy traps

  • Writing if (x = 5) in a condition isn't a comparison — it's an assignment. To check for equality, use if (x == 5).
Operators | Thuta Learning