COSC 071: Computer Science I

Homework 2
Spring 2000

Written due in 2nd lecture of week Jan 24-28
E-mail due: Jan 25 @ 5 PM
5 points

This homework is designed to get you familiar with entering and compiling C++ programs in a UNIX environment, something we'll do a lot of this semester.

  1. Draw a flowchart for your solution to Problem 3 of Homework 1.

  2. Using GNU g++, enter, compile, and run the C++ programs Program 2.1 (page 49), 2.2 (page 51), 2.6 (page 55), 2.8 (page 67), Program 2.9 (page 73), and Program 2.11 (page 92).

    You can find the GNU g++ compiler on either gusun or cssun, which are UNIX machines. You can telnet to these machines from the Internet or from a Win95 machine on the campus network.

    The editors on gusun and cssun are named ``vi'', which is a full-screen editor, and ``pico'', which is also a full-screen editor. The documentation for these editors is avilable on-line. For vi, type at the UNIX prompt ``man vi''. For pico, once inside the editor, you can type Control-G to get help. Note that vedit is a version of vi that is intended for beginners. You could also enter the source code on a Win95 machine and ftp it into your account on one of the UNIX machines.

    We'll cover much of this in the therapy sessions held this week.

  3. Do exercises 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 2.12, 2.17, 2.18 on pages 95-98 in Cohoon and Davidson and submit these written exercises in lecture.

    Note: For problem 2.8, remove both include statements.

  4. E-mail an electronic version of Program 2.11 to your TA. Use the last four digits of your student ID and the suffix ``.cc'' as the subject line.

    For example, if the last four digits of your student ID is 1234, the name of your source file is prog211.cc, and your TA's e-mail address is ``imagoodta@georgetown.edu'', then you would type at the UNIX prompt:

    gusun% mailx -s "1234.cc" imagoodta@georgetown.edu < prog211.cc
    
    You are executing the mailx command. The -s option indicates that the string "1234.cc" is the subject heading. imgagoodta@georgetown.edu is the address to which the mail will be sent. The part ``< prog211.cc'' takes your source file and directs it into the mailx command.

    You can also use pine to submit your project. After filling in the To and Subject fields (no spaces before or after), type the ^R command in the MESSAGE TEXT screen. Pine will ask for a file name (e.g., proj211.cc), which it will then load as your message text. Type ^X to send the e-mail to your TA.

    You must e-mail your project before 5:00 P.M. on the due date.