Professional Documents
Culture Documents
Spring - 2013
solution
b. operation
c. identity
d. address
b. A variable
c. A statement
d. A function
4. Forgetting to put a semicolon at the end of a cout statement is an example of a _________ error.
a. logic
b. syntax
c. runtime
b. a syntax error
c. no errors
6. Assuming the int variables m and n store the values 1 and 0 respectively, the C++ statement:
m = m / n;
has ________________.
a. a runtime error
b. a syntax error
c. no errors
int n = 2;
n = n + 10 / n;
b. 6
c. 7
d. 12
a. 1
b. 10
b. 48.6
c. 48
d. 49
e. 86
f.
e. 514
f.
b. 48.6
c. 48
d. 4
b. 7
c. 2
d. 1.0
e. 2.0
f.
0.0
12. What is the value stored in s after the following statements execute if when prompted for input
the user enters the characters in the box and then presses the Enter key.
string s = "default";
cout << "What's your name? ";
cin >> s;
a. Kobe Bryant
b. Kobe
user input
Kobe Bryant
c. Bryant
d. k
e. t
f. default
13. What is the value stored in n after the following statements execute if when prompted for input
the user enters the characters in the box and then presses the Enter key.
int n = 0;
cout << "Enter a number: ";
cin >> n;
a. 0
b. 1
user input
12abc
c. 2
d. 12
e. 12abc
f.
'c'
14. What is output by the following statements if when prompted for input the user enters the
a. 10
20
b. 34
978
user input
34 978
c. 34
20
d. 34
78
a. Lakers vs
b. LLaakkeer
c. Lakers vs.
d. LLaakkeerrss
vvss
e. Lake
f. Laker
16. What is the value of the following expression assuming the int variable n stores the value -5 and
b. false
17. What is the value of the following expression assuming the int variable n stores the value 20?
b. false
a. 100
b. 98
c. 50
d. 48
e. 6
f.
a. ab
b. bc
c. ac
d. abbc
e. bcac
f.
abac
d. abbc
e. bcac
f.
xyz
a. ab
b. bc
c. ac
a. ab
b. bc
c. ac
d. xyz
22. What is the value stored in sum after the following statements execute if when prompted for
input the user enters the characters in the box and then presses the Enter key.
int sum = 0;
int entry = -1;
cout << "Enter several integers all on one line: ";
while (entry <= 10)
{
cin >> entry;
sum = sum + entry;
}
a. 2
b. 12
c. 19
d. 31
user input
1 5 8 3 2 12 7 0
e. 38
f.
37