🎙️ Introduction
Hello everyone!
In the previous chapter, we studied Arithmetic Operators, which perform mathematical calculations.
Now let me ask you something:
👉 How does a program decide whether a student passed or failed?
👉 How does it check if one number is greater than another?
👉 How does it control loops based on conditions?
The answer is — Relational Operators.
In this chapter, we will clearly understand what...Read More
🔹 Step 1: What Are Relational Operators?
Relational operators are used to compare two values.
They check the relationship between operands and return a result.
The result is always:
True (1)
OR
False (0)
In simple words:
👉 Relational operators compare values and help...Read More
🔹 Step 2: Types of Relational Operators in C
C language provides six relational operators:
1️⃣ Equal to (==)
2️⃣ Not equal to (!=)
3️⃣ Greater than (>)
4️⃣ Less than (<)
5️⃣ Greater than or equal to (>=)
6️⃣ Less than or equal to (<=)
Let us understand each one clearly...Read More
🔹 Step 3: Equal To (==)
The equal-to operator checks whether two values are equal.
Example concept:
If a = 10 and b = 10
Then:
a == b → True
Important:
Do not confuse:
= (Assignment operator)
== (Relational operator)
This is a very common mistake by...Read More
🔹 Step 4: Not Equal To (!=)
This operator checks whether two values are different.
If a = 10 and b = 5
Then:
a != b → True
It returns true when values are...Read More
🔹 Step 5: Greater Than (>)
This operator checks whether the left operand is greater than the right operand.
If a = 10 and b = 5
Then:
a > b → True
Used in conditions like...Read More
🔹 Step 6: Less Than (<)
This operator checks whether the left operand is less than the right operand.
If a = 5 and b = 10
Then:
a < b → True
Commonly used in loops like...Read More
🔹 Step 7: Greater Than or Equal To (>=)
Checks whether the left value is greater than or equal to the right value.
If marks = 40
Then:
marks >= 40 → True
Useful in pass/fail conditions...Read More
🔹 Step 8: Less Than or Equal To (<=)
Checks whether the left value is less than or equal to the right value.
Example:
age <= 18
Used in age-based conditions...Read More
🔹 Step 9: How Relational Operators Work Internally
Relational operators return:
1 → True
0 → False
These values are used by control statements to decide program flow.
For example:
If condition is true (1), the block executes.
If condition is false (0), it does not execute...Read More
🔹 Step 10: Real-Life Example
Imagine a school grading system.
If marks >= 90 → Grade A
If marks >= 75 → Grade B
If marks >= 40 → Pass
If marks < 40 → Fail
All these conditions use relational operators.
Without them, decision-making is impossible...Read More
📌 Summary
In this chapter, we learned:
Relational operators compare two values.
They return:
True (1)
False (0)
The six relational operators are...Read More
Top comments (0)