A while statement to a for statement - confused!
Posted: Tue Jun 15, 2010 3:51 pm
I have to print a while statement odd numbers between 1 - 49 then change it to a for statement and this is what I got so far!
Can't figure out the rest...........
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>Odd Numbers</title>
</head>
<body>
<?php // Script 6.2 - Odd Numbers
// Address error handling.
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
/*Odd Numbers */
// Validate the Odd Numbers.
$i = 1;
$i < 1 && $i => 49 {
echo $i++;
// Print out odd numbers between 1-49.
for($i = 0;$i < 50;++$i) {
if($i % 2) {
echo "$i is odd!<br />\n";
}
}
?>
</body>
</html>
Can't figure out the rest...........
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>Odd Numbers</title>
</head>
<body>
<?php // Script 6.2 - Odd Numbers
// Address error handling.
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);
/*Odd Numbers */
// Validate the Odd Numbers.
$i = 1;
$i < 1 && $i => 49 {
echo $i++;
// Print out odd numbers between 1-49.
for($i = 0;$i < 50;++$i) {
if($i % 2) {
echo "$i is odd!<br />\n";
}
}
?>
</body>
</html>