Nearby lessons

19 of 72

C - Relational Operators

Relational Operators is one of the foundational topics in C programming. This lesson explains Relational (Comparison) Operators (== != < > <= >=) and Program: all six relational operators with complete, runnable code examples, clear step-by-step explanations, and common mistakes to avoid with exam-style MCQs at the end.

Relational (Comparison) Operators (== != < > <= >=)

These compare two values and give either true (1) or false (0). C has no boolean word for beginners — it uses 1 for true and 0 for false.

OperatorMeaningExample
==Equal toa == b
!=Not equal toa != b
<Less thana < b
>Greater thana > b
<=Less than or equal toa <= b
>=Greater than or equal toa >= b
In simple words: a comparison always answers one question — true or false. In C, true is printed as 1 and false as 0. No other answer is possible.

Program: all six relational operators

Example02
Loading editor…
📝 Key Takeaways
  • Operators: arithmetic (+ - * / %), relational (== != < > <= >=), logical (&& || !), assignment (= += -= *= /= %=), ++ --, ternary ?:.
  • Each operator family has its own complete program — copy and run one at a time.
  • Integer division drops decimals: 5/2 = 2; use 5.0/2 for 2.5.
  • % gives the remainder and works only on integers.
  • a++ uses then increases; ++a increases then uses.
  • Ternary: condition ? value1 : value2.
  • Use brackets to control the order of evaluation.

🧠 Test Your Knowledge

1 Questions
Progress: 0 / 1

Finished this lesson?

Mark it as complete to track your progress and see technology completion stats.