Name: ____________________________________________________ Alpha: _____________________

Describe help received: _________________________________________________________________

  1. [10pts] Consider the following code:
    
    while( cin )
    {
      int a = 100;
      cin >> a;
      cout << a << endl;
    
      int b = 200;
      cin >> b;
      cout << b << endl;
    }
    
    Suppose that the user gives the following input:
    hello
    What will be the output of the program? Why?
    
    
    
    
    
    
    
  2. [90pts] Write a program that reads in a file like this:

    3
    4
    23 788 12 -6 
    0 2 -337 -8923 
    25656 -89 0 1

    that contains a table of integers in unformatted text.

    The program will write out a file output.html that shows the same table in html, which looks like this

    <table border=2>
    <tr><td>23</td><td>788</td><td>12</td><td>-6</td></tr>
    <tr><td>0</td><td>2</td><td>-337</td><td>-8923</td></tr>
    <tr><td>25656</td><td>-89</td><td>0</td><td>1</td></tr>
    </table>

    which, when opened in a web browser, will render like this: output.html.

    You may assume that the file is named input.txt, and that the first line of the file tells you how many rows in the table, the second line tells you how many columns, and that the subsequent lines contain the the values to appear in the table. Look at w3 tables intro if you need a little help with tables in HTML.

    With input.txt, the result should look like: output.html. To check if your program creates the correct output.html file, it may be useful to open that file using a web browser (use ctrl-o) and see how it looks.

Turn in