Difference between revisions of "CSC220 Lab 3 2010"

From dftwiki3
Jump to: navigation, search
(Fourth Problem)
(Fourth Problem)
Line 65: Line 65:
 
       <tr><td>10 odd</td></tr>
 
       <tr><td>10 odd</td></tr>
 
       </table>
 
       </table>
</code></pre>
+
</pre></code>
  
 
<br />
 
<br />

Revision as of 18:43, 19 September 2010

--D. Thiebaut 23:42, 19 September 2010 (UTC)


First Problem

  • Write a php page that declares 2 variables $a, and $b, set both of them to some values of your choice, and displays their contents, sum, and difference.
  • Your page should display something like this:
$a = 5
$b = 10
$a + $b = 5 + 10 =  15
$a - $b = 5 - 10 =  -5
  • Make sure you create your page in your ~220a-xx/public_html directory, and remember to chmod a+r your Php files!

Second Problem

  • Write a Php page that uses a for loop and that displays all the numbers from 1 to 10, as follows:
1
2
3
4
5
6
7
8
9
10

Third Problem

  • Same as Problem 2, but add a test in your loop so that the output becomes as shown below:
1 odd
2 even
3 odd
4 even
5 odd
6 even
7 odd
8 even
9 odd
10 even


Fourth Problem

  • Same as Problem 3, but this time the 10 lines are output in an html table.
  • The code for the table should look something like this:
       <table>
       <tr><td>1 odd</td></tr>
       <tr><td>2 odd</td></tr>
       <tr><td>3 odd</td></tr>
       <tr><td>4 odd</td></tr>
       <tr><td>5 odd</td></tr>
       <tr><td>6 odd</td></tr>
       <tr><td>7 odd</td></tr>
       <tr><td>8 odd</td></tr>
       <tr><td>9 odd</td></tr>
       <tr><td>10 odd</td></tr>
       </table>










[[Category:CSC220]