Quizzes are given on a more-or-less random basis. Missed quizzes may not be made up.
| # | Quiz | Date |
|---|---|---|
|
12
13
14 |
Given the declarations: struct Book { string ISBN; string Title; string Author; int Quantity; }; Book DWH; Book Lib[100];
Write statements to perform the indicated action:
Store the string "C++ for Dummies" in the appropriate field of the variable DWH.
Print the ISBN of the 20th Book in the array Lib to standard output.
Swap the 17th and 36th Books in the array Lib.
|
Nov 28 |
|
9 10 11 |
|
|
|
5
6
7
8 |
Consider executing the following code:
int
a, b;
// line 1 bool
x, y, z;
// line 2 a
= _______;
// line 3 x
= _______;
// line 4 y
= _______;
// line 5 z
= true;
// line 6 b
= 0;
// line 7 while
(a <= 10) { //
line 8
while (x) {
// line 9
if (y == z) {
// line 10
b++;
// line 11
_________; // line 12
}
else
x = !x;
// line 13
}
a++;
// line 14 }
With a initialized to 1, x initialized to true and y initialized to false: How many times is line 14 executed? 10 How many times is line 11 executed? 0
With a initialized to 1, x initialized to true and y initialized to true: How many times is line 14 executed? 0 How many times is line 11 executed? infinitely many
With the same initializations as in 6, and changing line 12 to: y = !y; How many times is line 11 executed? 1
What initialization(s) would guarantee that lines 10 through 14 would never be executed? a = 32; Yes a = -5; No x = false; No |
Oct 10 |
|
3
4 |
Consider reading an input file of the form: 1234567890 1234567890 1234567890
What is the value of x after execution of the following code? 890 int x; char ch; In.ignore(7, '\n'); In >> x;
What is the value of x after execution of the following code? '8' int x; char ch; In.ignore(10, '7'); In >> x;
|
? |
| 2 |
How could the following statement be expressed using the increment
operator:
Either of the following answers will do:
Note: the following statements will also increment NumValues, but inefficiently and not really making proper use of the increment operator.
|
Sept 8 |
|
1 |
Determine whether each of the following is a valid identifier in C++:
|
Sept 5 |
Please send comments and suggestions to William McQuain at mcquain@cs.vt.edu.