UBC 2024-CPSC 121 Review
Study online at https://quizlet.com/_gabqt9
1. Which among the following statements will produce this output on screen?
Select all that apply.
Tell me who your friends are,
and I'll tell you mine!
a) cout << "Tell me who your friends are," << endl << "and I'll tell you mine!";
b) cout << "Tell me who your friends are";
cout << "and I'll tell you mine!";
c) cout << "Tell me who your friends";
cout << "are,\nand I'll tell you mine!";
d) cout << "Tell me who your friends are," << endl;
cout << "and I'll tell you mine!";: a, c, d
2. Why does the code below fail to compile?
#include <iostream>
using namespace std;
int main ()
{
cout << "\"I'm here", John said" << endl;
return 0;
}
The code's expected output is shown below:
"I'm here", John said
Select one:
a) The " after the word here in the code incorrectly terminates the string.
b) There are no errors in the code and it produces the expected output.
c) The \" before the word I'm in the code in unnecessary.
d) The " after the word said in the code needs to be escaped (replace with \")
to properly terminate the string.: a
3. Identify the type of literal below.
"algorithm": string literal
4. Identify the type of literal below.
'Z': character literal
1/7
, UBC 2024-CPSC 121 Review
Study online at https://quizlet.com/_gabqt9
5. Identify the type of literal below.
"121": string literal
6. Identify the type of literal below.
121: integer literal
7. Identify the type of literal below.
2018.09: floating-point literal
8. Identify the type of literal below.
5: integer literal
9. Why is the identifier below identify a C++ variable name? Select all that
apply.
4th_Section#2
Select one or more:
a) It starts with a number.
b) It contains uppercase characters.
c) It contains a # symbol.
d) It contains a _ symbol.: a, c
10. What will be the result of the following relational operation? Assume that
age is 20.
age >= 18
Select one:
a) true
b) false: a
11. Identify whether the following statements perform promotion or demotion.
cout << 4.0/3 << endl;: promotion
12. Identify whether the following statements perform promotion or demotion.
double cash = 1000;: promotion
13. Identify whether the following statements perform promotion or demotion.
int age = 15.6;: demotion
2/7
Study online at https://quizlet.com/_gabqt9
1. Which among the following statements will produce this output on screen?
Select all that apply.
Tell me who your friends are,
and I'll tell you mine!
a) cout << "Tell me who your friends are," << endl << "and I'll tell you mine!";
b) cout << "Tell me who your friends are";
cout << "and I'll tell you mine!";
c) cout << "Tell me who your friends";
cout << "are,\nand I'll tell you mine!";
d) cout << "Tell me who your friends are," << endl;
cout << "and I'll tell you mine!";: a, c, d
2. Why does the code below fail to compile?
#include <iostream>
using namespace std;
int main ()
{
cout << "\"I'm here", John said" << endl;
return 0;
}
The code's expected output is shown below:
"I'm here", John said
Select one:
a) The " after the word here in the code incorrectly terminates the string.
b) There are no errors in the code and it produces the expected output.
c) The \" before the word I'm in the code in unnecessary.
d) The " after the word said in the code needs to be escaped (replace with \")
to properly terminate the string.: a
3. Identify the type of literal below.
"algorithm": string literal
4. Identify the type of literal below.
'Z': character literal
1/7
, UBC 2024-CPSC 121 Review
Study online at https://quizlet.com/_gabqt9
5. Identify the type of literal below.
"121": string literal
6. Identify the type of literal below.
121: integer literal
7. Identify the type of literal below.
2018.09: floating-point literal
8. Identify the type of literal below.
5: integer literal
9. Why is the identifier below identify a C++ variable name? Select all that
apply.
4th_Section#2
Select one or more:
a) It starts with a number.
b) It contains uppercase characters.
c) It contains a # symbol.
d) It contains a _ symbol.: a, c
10. What will be the result of the following relational operation? Assume that
age is 20.
age >= 18
Select one:
a) true
b) false: a
11. Identify whether the following statements perform promotion or demotion.
cout << 4.0/3 << endl;: promotion
12. Identify whether the following statements perform promotion or demotion.
double cash = 1000;: promotion
13. Identify whether the following statements perform promotion or demotion.
int age = 15.6;: demotion
2/7