Lab 1

Overview

This lab gives you a chance to use the debugger and your own detective ability to find and fix the error(s) in a program.

Directions

Begin by creating a new workspace named labs111, or similar, on your M drive. Then create a new project within it named lab1. Then use MyComputer (or Windows Explorer) to copy the file buggy.cpp from your Cs111 mapped network drive's subdirectory named Common to the lab1 directory within your new workspace directory on M. Use Project, Add to Project, Files to add the buggy.cpp file to the lab1 project.

In the comment section at the top of the program, add a line that gives the names of those in your group. For example, you might use:

Revised by A. Student, I. Student, and J. Student on 1/**/2001.

Use Build, Rebuild All to try to compile the program. If there are any syntax errors, they should appear in a window at the bottom. Starting at the top of the list of errors, double click on each to bring up the line where the error occurred. (Note that sometimes the error actually occurred on the previous line or even an earlier line. The compiler cannot catch all errors exactly when they occur.) Fix any syntax errors that were found. Keep rebuilding the program until no syntax errors remain.

Syntax errors are the easy stuff. Now let's see if the program works correctly. Read the comments at the top of the program to see what it is expected to do. Then run it and see if it does indeed do this. If not, there is a logic error (or several) in the program. Use the debugger to step over the lines of code in the main function to try to get an idea of where the error is occurring. Watch the values of the variables to see whether they are reasonable. Play detective, looking for clues as to what might be going wrong.

If that does not locate the error(s), use the debugger to step into one or both of the helping functions in the program. Then step over the lines of code in the function. Look for clues as to why the program produces the wrong output.

Once you have found the problem, fix things so that the program works correctly. There may be several ways to fix the program. Try to pick the best method.

Fill in the missing comments for the two functions so that they correctly describe how the functions work in terms of their parameters.

Finally, use MyComputer to copy your corrected buggy.cpp file to the Hw111 homework submission mapped network drive for one member of your group. As long as the names of all group members are in the file, all will receive credit. Your instructor will look at the file to see how you have done.