Computer Science 131
Introduction To Computing

Dickinson College
Fall Semester 1997
Grant Braught


Vectors in C++


Sample Code

Below are links to the sample programs that were used in class:

Practice Exercises

  1. Predict the output that would be generated by running the RefPuzzle.cpp program.

  2. Describe what happens if in VectorDemo.cpp you only read 5 itmes into the list, i.e. GetList(theList,5), but then try to print out 10 items from the list, i.e. PrintList(theList,10). What does this mean about the default values of the vector elements?

  3. Add a function called SelectSort to the VectorDemo program. This function should sort the list that is entered using the selection sort algorithm. Your new program should read in a list of numbers to the vector, sort the list and then print out the sorted list.

    Solution: SelectSort.cpp