- 1

Pls correct this my code i want to write Even and Odd number.

<?php for($a=0;$a<100;$a++){ if($a℅2==0){ echo"this is even number:".$a."<br/>"; } else { echo"this is odd number".$a."<br/>"; } } ?>

26th Feb 2017, 11:27 AM
AZZEETECH INFORMATION TECHNOLOGY
AZZEETECH INFORMATION TECHNOLOGY - avatar
2 Answers
+ 5
use %
26th Feb 2017, 11:39 AM
Mario L.
Mario L. - avatar
+ 4
short version: <?php for($i=0;$i<100;$i++){ echo $i." is ".(($i%2==0) ? "even" : "odd") ."<br>"; } ?>
26th Feb 2017, 11:58 AM
Mario L.
Mario L. - avatar