Quiz 5 preparation material
Quiz 5 will be 50 minutes long, handwritten, and conducted in the first half of
the weekly lab session.
The quiz will be closed book, closed notes, and no electronics permitted,
but students will be permitted one double-sided 8.5x11" 'cheat sheet'. (These do not need to
be handwritten.)
Some questions on the quiz may ask you to write short explanations/descriptions of different
aspects of C++, some will ask you to write short C++ code segments to achieve specific results,
some will ask you to show and/or explain the results of short C++ code segments.
The topics and suggested preparation activities for the quiz are listed below.
As with prior quizzes, the best way to practice coding in general is to write and debug as many small programs as
you have time for. The best way to practice for hand-written quizzes and exams is to try
writing small programs on paper then take your answers and type them in/debug them to see
where the bugs are. If you need a refresher on how to write/compile 'from scratch' programs
(as opposed to the ones in the provided lab and make files), see the notes near the
top of the quiz 1 prep material.
- structs
- There will likely be a question along the lines of "declare/define a struct named X whose
fields are A of type B and C of type D".
- There will likely be a question asking you to write a function that takes a struct (of the type
X from the previous question) as a parameter and does something with/to it (e.g. fill the fields
from user input, print the contents, do some calculation based on the contents, etc).
- arrays of structs
- Given a definition for a particular struct type, a typical question would be to write code
to process all the elements of an array of those structs (e.g. fill all the elements, print
all the elements, search for an element containing a particular value in one of its fields,
etc).