369 TESLAKALVIYOGI
Page 19 of 30

Comparison Operators

==, !=, >, <, >=, <=

</> logic
1

Concept Meaning

Comparison operators compare two values and return true or false.

2

Real-Life Analogy

A teacher compares mark with pass mark to decide pass or fail.

3

Expected Output

10 > 5 → true
4

Common Mistake

Do not confuse = assignment with == comparison.

Same Logic • Different Syntax

Code in 4 Languages

JavaScript
let a=10,b=5;
console.log(a==b,a!=b,a>b,a<b,a>=b,a<=b);
C++
int a=10,b=5;
cout<<(a==b)<<(a!=b)<<(a>b);
Python
a=10
b=5
print(a==b,a!=b,a>b,a<b,a>=b,a<=b)
PHP
<?php
$a=10;$b=5;
echo $a==$b;
echo $a!=$b;
echo $a>$b;
?>

Memory Tip

Compare values → get true or false.