CS107 - Lab 7
High Level Languages and C++ Programming

Due Tuesday 11/4

Overview:

This assignment introduces the elements of C++ programming. The key challenge here is, "How do software designers write programs for real applications, and how are they translated (compiled) to run on a computer?" The readings and exercises for this assignment are taken from portions of chapter 7 of your text.


Compiling and Running a C++ program

Following the same steps that you used for Assignment 2, double-click the icon csci107 - Invitation (OSX) that you copied to the desktop. The button C++ Compiler is used for this assignment. When you select it, Open the file fig12.cpp in the Desktop -> Invitation -> Examples directory, and then select Compile in the Compiler menu. The following result should appear on your screen.

This window has two columns. On the left is a listing of the original C++ program and on the right is a copy of that listing that is checked for errors and compiled (The actual machine code doesn't appear here).

Now select Execute in the Compiler menu, and then select the Run button at the bottom. You will be prompted to enter two 4-digit numbers. This program should behave just like the pseudocode algorithm that we first saw in Figure 1.2, but now it's been rewritten in C++. You should be able to duplicate the output shown below.

Now open, compile, and run the program "fig25.cpp" in the EXAMPLES folder.

1. Describe briefly in English what this program does.

Now open, compile, and run the program "fig29.cpp" in the EXAMPLES folder.

2. Describe briefly in English what this program does.

Now open, compile, and run the program "fig210.cpp" in the EXAMPLES folder.

3. Describe briefly in English what this program does.

Algorithmic Problem Solving

Complete your answers to the above three questions, and then complete Exercises 2, 5, 6, 11, 14, 19, 22, 24. and 30 on page 367 of your text. All of these can be handwritten except for Exercise 30, which should be written and run correctly using the C++ Compiler described above. Submit your completed program to the csci107 -> Drop Box when you have completed it.



You may do these exercises (except the last one) either by hand or with a word processor (e.g. MS Word). Also, you may choose to do this assignment either by yourself or in a group. However, solutions should be written up individually and handed in on the due date.

To submit a file electronically, you should first rename it so that you are identified as the author (e.g., give it a name like lab-x-ltoma). Then drag the file to the csci107 -> Drop Box folder. Be careful not to drag an entire folder into the Drop Box; only a single file at a time can be submitted.

Once you are finished in the lab, be sure to drag the CS107 icon to the Trash - this step disconnects you from the server and prevents someone else (who may use this iMac later in the day) from accidentally accessing files in your personal folder.