CS111 Quiz 2
What will the following code display? int x = 0, y = 1, z = 2; cout << x << y << z << endl;
012
What will the value of x be after the following statements execute? int x; x = 24/(1 + 2%3 + 4/5 + 6 + 31%8);
1
What will the value of x be after the following statements execute? double x; x = 3.0 / 6 + 18 / (15 % 4 + 2);
3.5
Which of the following correctly consolidates the following declaration statements into one statement? int x = 7; int y = 16; int z = 28;
int x = 7, y = 16, z = 28;
Assume that a program has the following variable definition: char letter; Which of the following statements correctly assigns the character Z to the variable?
letter = 'Z';
What will the following code display? cout << "Four\n" << "score\n"; cout << "and" << "\nseven"; cout << "\nyears" << " ago" << endl;
Four score and seven years ago
What will the following code display? cout << "Four " << "score "; cout << "and " << "seven/n"; cout << "years" << "ago" << endl;
Four score and seven/nyearsago
What will the following code display? cout << "Four" << "score" << endl; cout << "and" << "seven" << endl; cout << "years" << "ago" << endl;
Fourscore andseven yearsago
What will the following code display? int number = 7; cout << "The number is " << "number" << endl;
The number is number
Assume that a program has the following string object definition: string name; Which of the following statements correctly assigns a string literal to the string object?
name = "Jane";