369 TESLAKALVIYOGI
Page 26 of 30

For Loop Introduction

Repeating task concept: counting 1 to 10

</> logic
1

Concept Meaning

A for loop repeats a block of code a fixed number of times.

2

Real-Life Analogy

Teacher asks a student to count 1 to 10 one by one.

3

Expected Output

1 2 3 4 5 6 7 8 9 10
4

Common Mistake

Forgetting to increase the loop value can cause an infinite loop.

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

Start → Check → Print → Increase → Repeat.