Difference between revisions of "CSC220 Homework 2 2010"

From dftwiki3
Jump to: navigation, search
(Problem #1)
(Problem #1)
Line 19: Line 19:
 
</table>
 
</table>
  
* Store your Php program in a file called hw2_1.php and submit it as follows:
+
* Store your Php program in a file called hw2a.php and submit it as follows:
  
 
   submit hw2 hw2a.php
 
   submit hw2 hw2a.php
Line 27: Line 27:
 
** Do not reinvent the wheel.  It is acceptable to lookup the algorithm for computing Pascal's triangle.   
 
** Do not reinvent the wheel.  It is acceptable to lookup the algorithm for computing Pascal's triangle.   
 
** Do not hesitate to code in a different language, as a way to approach this.  If Java is more comfortable for you, do the coding in Java first, to prove to yourself that you understand the algorithm, then pass to Php.
 
** Do not hesitate to code in a different language, as a way to approach this.  If Java is more comfortable for you, do the coding in Java first, to prove to yourself that you understand the algorithm, then pass to Php.
 +
 +
=Problem #2=
 +
 +
* Same idea and algorithm as for Problem #1.  But this time make your Php code display the first line of the Pascal Triangle that contains a term larger than 1000.
 +
 +
* Your program should output only one series of numbers, which is the given line in the triangle. 
 +
 +
* Store your program in a file called hw2b.php and submit it as follows:
 +
 +
  submit hw2 hw2b.php
 +
 +
* Hints:
 +
** the line should contain 14 terms...
 +
** you may want to display them in an HTML list if you want, or on a single line.
 +
 +
 
<br />
 
<br />
 
<br />
 
<br />

Revision as of 13:57, 22 September 2010

--D. Thiebaut 18:45, 22 September 2010 (UTC)


Page under construction!
UnderConstruction.jpg

Problem #1

  • Write a Php program that displays the first 10 rows of Pascal's Triangle in a table using loops and arrays. The first 5 lines of the array are shown below.
    
1   
1  
1 
1
  • Store your Php program in a file called hw2a.php and submit it as follows:
 submit hw2 hw2a.php
  • Hints:
    • Make your table display with borders. Feel free to format the rest of the page as you see fit.
    • Do not reinvent the wheel. It is acceptable to lookup the algorithm for computing Pascal's triangle.
    • Do not hesitate to code in a different language, as a way to approach this. If Java is more comfortable for you, do the coding in Java first, to prove to yourself that you understand the algorithm, then pass to Php.

Problem #2

  • Same idea and algorithm as for Problem #1. But this time make your Php code display the first line of the Pascal Triangle that contains a term larger than 1000.
  • Your program should output only one series of numbers, which is the given line in the triangle.
  • Store your program in a file called hw2b.php and submit it as follows:
 submit hw2 hw2b.php
  • Hints:
    • the line should contain 14 terms...
    • you may want to display them in an HTML list if you want, or on a single line.