- 2

Using the for loop, print only the even numbers between 0 and 10. for ($i=0; $i<=10;$i++) { { } } if ($i%2 != 0)

Help crack this

15th Feb 2017, 1:30 PM
Collins Mutuma Gituma
Collins Mutuma Gituma - avatar
4 Réponses
+ 5
for ($i=0; $i<=10;$i++) { if ($i%2 != 0) { continue; } echo $i."<br/>"; }
27th Jul 2019, 5:07 PM
Cheddad Zoher
+ 1
//Freebie Only one change is needed. if($i%2!=0) should be if($i%2==0) then it should print $i
15th Feb 2017, 1:38 PM
Ghauth Christians
Ghauth Christians - avatar
0
for ($i=0; $i<=10;$i++) { if ($i%2 != 0) { continue; } echo $i."<br/>"; }
28th Jul 2020, 11:08 AM
sonajosf
sonajosf - avatar
- 5
no need to test if the number is even or not; for ($i=0; $i<=10;$i= $i + 2) directly print $i
15th Feb 2017, 1:57 PM
Chaieb Mohamed Yassine
Chaieb Mohamed Yassine - avatar