JavaScript
for(let i=1;i<=10;i++){
if(i%2==0) console.log(i);
}Printing even numbers / multiplication table
A loop with condition repeats steps and prints only selected values based on a rule.
Teacher asks students to write only even roll numbers or the 5 times table.
Condition selects the output. Wrong condition gives wrong values.
for(let i=1;i<=10;i++){
if(i%2==0) console.log(i);
}for(int i=1;i<=10;i++){
if(i%2==0) cout<<i<<endl;
}for i in range(1,11):
if i%2==0:
print(i)<?php
for($i=1;$i<=10;$i++){
if($i%2==0) echo $i."<br>";
}
?>Loop repeats. Condition selects.