How would you use an if statement to print the string "Youth message" to the browser if an integer variable, $age, is between 18 and 35? If $age contains any other value, the string "Generic message" should be printed to the browser.
How would you extend your code in question 1 to print the string "Child message" if the $age variable is between 1 and 17?
How would you create a while statement that prints every odd number between 1 and 49?
How would you convert the while statement you created in question 3 into a for statement?
$age = 22; if ( $age >= 18 && $age <= 35 ) { print "Youth message<br />\n"; } else { print "Generic message<br />\n"; }
$age = 12; if ( $age >= 18 && $age <= 35 ) { print "Youth message<br />\n"; } else if ( $age >= 1 && $age <= 17 ) { print "Child message<br />\n"; } else { print "Generic message<br />\n"; }
$num = 1; while ( $num <= 49 ) { print "$num<br />\n"; $num += 2; }
for ( $num = 1; $num <= 49; $num += 2 ) { print "$num<br />\n"; }