This lab consists of three C++ exercises that correspond to Scheme exercises
you have already done.
Be sure that you have gone through
Using C++ at UMD (see menu at left)
before starting this exercise.
Exercises 1, 2, and 3 referred to below are not in the text.
However, the summary below gives the pages where the problems are discussed.
Exercise |
Problem |
Text Page |
Points |
1 |
Counting the sixes in a number |
39 |
2 |
2 |
Summing up function values on an integer range |
113 |
2 |
3 |
The game of Nim |
135–143 |
11 |
Exercises 1 and 2 will be done in one file, while exercise 3 will have its own file.
Download the following files for this exercise:
Their listings are shown through the menu at the left.
The files contain comments describing the functions they contain.
You should be able to compile (but not yet run) these files.
Each of the functions you must write is defined in its file without a body.
You should look in the
main function of each file to see how the functions
are to behave. There also are comments describing the functions.
When you have written a function and are ready to test it (for any of the
exercises), you must compile it:
- It helps to comment out any code in the main
function that calls functions you have not yet written and tested
- Compile the file following the procedure described in Compiling and
Running C++ in the menu to the left.
-
Fix any syntax errors.
Run the executable file:
-
For all exercises, success messages will be shown when a
function passes a test.
-
For Exercise 3 you will in addition be directed by the test
program to input certain values at the keyboard for testing.
You are finished when both your
exercises.cpp and
nim.cpp files
compile and run without assertion errors, and you can run a game of Nim to completion.
When finished, submit your
exercises.cpp and
nim.cpp
files to
Lab Exercise: Intro to C++ in
.
The grader will test your code by compiling and running it and checking
that all assertions succeed and that Nim runs correctly to completion.