Sunday, October 5, 2008

Some PHP practice problems

Given:

<?php
echo "Please enter your name: ";
$name = trim (fgets (STDIN));
echo "Welcome, $name\n";

if ($name == "Sushil")
echo "You rock!!!\n";

print "I'm now going to count to 10\n";

for ($i=1; $i <=10; $i++)
echo $i . " ";

echo "\n";
?>


extend to the following:
  1. read three numbers and print the square of each,
  2. read three numbers, sort them, and print the square of each,
  3. print the even numbers from 0 to 20, and
  4. print the current date.
A useful resource is the php tutorial.

No comments: