Labs ICT
⭐ Pro Login

Relational Operators

1 min read | C Tutorial
⭐

Want the full learning experience?

Get structured courses, certificates, projects, and instructor support with LabsICT Pro.

Explore Pro Courses

Relational operators let you compare values. Is one thing bigger than another? Are they equal? These operators give you a 1 (true) or 0 (false). They are the backbone of decision-making in C.

The Comparison Operators

  • == — equal to (do not confuse with =, which assigns)
  • != — not equal to
  • < — less than
  • > — greater than
  • <= — less than or equal to
  • >= — greater than or equal to

The double equals == trips up beginners constantly. A single = assigns a value. Double == checks equality. Use the wrong one and your program will behave strangely.


#include <stdio.h>

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

  printf("x == y: %d\n", x == y);
  printf("x != y: %d\n", x != y);
  printf("x < y: %d\n", x < y);
  printf("x > y: %d\n", x > y);
  printf("x <= y: %d\n", x <= y);
  printf("x >= y: %d\n", x >= y);
  return 0;
}