369 TESLAKALVIYOGI
Page 27 of 30

For Loop in 4 Languages

Syntax comparison with number printing

</> logic
1

Concept Meaning

All four languages can use loops to print numbers, but the syntax style differs.

2

Real-Life Analogy

Same counting activity written in four notebook styles.

3

Expected Output

1 to 10 printed in order
4

Common Mistake

Python range(1, 11) stops before 11, so it prints 1 to 10.

Same Logic • Different Syntax

Code in 4 Languages

JavaScript
for(let i=1;i<=10;i++){
 console.log(i);
}
C++
for(int i=1;i<=10;i++){
 cout<<i<<endl;
}
Python
for i in range(1,11):
    print(i)
PHP
<?php
for($i=1;$i<=10;$i++){
 echo $i."<br>";
}
?>

Memory Tip

Same counting idea. Different writing style.