- 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
4 Réponses
+ 5
for ($i=0; $i<=10;$i++) {
if ($i%2 != 0)
{
continue;
}
echo $i."<br/>";
}
+ 1
//Freebie
Only one change is needed.
if($i%2!=0) should be if($i%2==0) then it should print $i
0
for ($i=0; $i<=10;$i++) {
if ($i%2 != 0)
{
continue;
}
echo $i."<br/>";
}
- 5
no need to test if the number is even or not;
for ($i=0; $i<=10;$i= $i + 2) directly print $i