(TCO
4)
What
is the
result
of 5
% 7?
(7
points)
0
2
5
7
Instructor Explanation: Malik, pages 39–40
MC Week 12, Final Attempt 3(Current Exam)
(TCO 4) A variable declared before and outside all function blocks (7
points)
is visible only in main.
is visible to all functions.
is visible to all functions except main.
is not visible to any functions.
Instructor Explanation: Malik, pages 50–65
MC Week 12, Final Attempt 3(Current Exam)
(TCO 4) What is the value of data after the following code
executes?
unsigned char data = 0xA5;
data = data & 0xF0;(7 points)
0xA0
0xF0
0xF5
0x5A
Instructor Explanation: Malik, pages 32–42
, MC Week 12, Final Attempt 3(Current Exam)
(TCO 4) What is the bit pattern in data after the following statements
execute?
unsigned int data = 10;
data = data | 0x0B;
data = data << 1;(7 points)
0x314
0x154
0x342
0x156
Instructor Explanation: Malik, pages 32–42
MC Week 12, Final Attempt 3(Current Exam)
(TCO 4) Why does this code snipper give a compile error?
int loopCounter = 0;
int numberOfScores = 20;
while (loopcounter < numberOfScores)
cout << “\nInside the loop”;(7 points)
The value of the control loop control variable does not change the loop body.
The curly brackets are missing around the loop body.
The loopCounter variable is not spelled consistently.
All of the above
Instructor Explanation: Malik, pages 32–42
MC Week 12, Final Attempt 3(Current Exam)
(TCO 4) Which of the following is not a C++ logical operator? (7 points)
#
&&
││
!
Instructor Explanation: Malik, pages 57–67
, MC Week 12, Final Attempt 3(Current Exam)
(TCO 4) What is the value of i after the following code fragment
executes?
int i = 2;
int k = 5 ;
i *= k + 1;(7 points)
7
11
12
14
Instructor Explanation: Malik, pages 57–67
MC Week 12, Final Attempt 3(Current Exam)
(TCO 4) Which looping statement is best if the number of iterations
is known?(7 points)
If/Else
For
While
Do/While
Instructor Explanation: Malik, pages 57–67
MC Week 12, Final Attempt 3(Current Exam)
(TCO 4) Which operation in the following expression will be
performed first?
c = a++ / b + 5;(7 points)
a
a/b
assignment to c
b+5
Instructor Explanation: Malik, pages 57–67
, MC Week 12, Final Attempt 3(Current Exam)
(TCO 4) What is the value stored in variable c, after the execution of
the following statement?
int a=5, b=2, c;
c = ++a / b + 5;(7 points)
7.5
8
7
0
Instructor Explanation: Malik, pages 57–67
MC Week 12, Final Attempt 3(Current Exam)
(TCO 4)
What is
the value
stored in
variable c,
after the
execution
of the
following
statement?
int a=5,
b=2, c;
c = a++ / b
+ 5;(7 points)
7.5
8
7
0
Instructor Explanation: Malik, pages 57–67
MC Week 12, Final Attempt 3(Current Exam)
(TCO 4) If firstName and lastName are string object variables,
which statement can be used to combine (append or
concatenate) the two into a single string variable?(7 points)
fullName = firstName + lastName;