CS 1005, C Term 2000
Techniques of Programming
Lab 4 (Feb. 9)
In this lab you will practice using the vector class.
I am providing a main()
function that fills a vector with the results of random die rolls.
You will write a function that returns the position of a given vector
in which a specified target item first occurs.
Sample runs of the finished program are available
- Sign in with the TA. You should both print your name
and sign the sheet.
- Listen to the TA's mini-lecture.
- Do the problems listed below. Feel free to ask the TA
questions about the problems. Don't worry if you can't
finish all of the problems before the lab session is over.
You can finish afterwards. However, actively working
on the lab assignment during the lab session is required.
Log onto your CCC Unix account.
Change the working directory to your CS1005 directory.
Create a subdirectory named Lab4 and change the working directory to Lab4.
Copy the files named lab4.cxx, dice.h, dice.cpp, randgen.h, randgen.cpp
from the /cs/cs1005/samples/lab4/ directory to your Lab4 directory.
Add the appropriate include directive to lab4.cxx so that
your program will be able to use the vector class.
Fill in the missing actual parameters in the invocation of
the function IndexOfFirstOccurrenceOf within main().
Fill in the missing body of the function IndexOfFirstOccurrenceOf
according to its specification.
Compile your program using the following command line:
g++ -o lab4prog lab4.cxx dice.cpp randgen.cpp
Debug your program as needed.
Try out your program for different numbers of rolls.
Use any remaining time to continue studying for Test 2.
One suggestion in particular is to try out problem 5
from the practice problems by writing (and running)
a suitable program while you're still in the lab.