Hacks
Consider the following code segment:
currentScore ⟵ 10 highScore ⟵ currentscore currentScore ⟵ 7 DISPLAY (currentScore)
- What will the currentScore be after running this code segment?
A. 17 b. 10 c. 7 d. none of the above
Answer = C
- What will the highScore be?
A. 17 b. 10 c. 7 d. none of the above
Answer = B
- Consider the following code segment:
num1 ⟵ 4 num2 ⟵ 6 num1 ⟵ num 2 DISPLAY(num1)
DISPLAY(num2)
- What is displayed after running this code segment?
A. 4 6 b. 6 4 c. 4 4 d. 6 6
Answer = D
- Consider the following code segment:
num1 ⟵ 25 num2 ⟵ 15 num3 ⟵ 30 num2 ⟵ num3 num3 ⟵ num1 num1 ⟵ num2 DISPLAY(num1)
DISPLAY(num2)
DISPLAY(num3)
- What is displayed after running this code segment?
A. 25 15 30 b. 30 30 25 c. 30 15 30 d. 15 30 25
Answer = B
Consider the following code segment:
p ⟵ 10 q ⟵ 20 r ⟵ 30 s ⟵ 40 p ⟵ q q ⟵ r s ⟵ q r ⟵ p
- What is the value of r as a result of running this code segment
A. 10 b. 20 c. 30 d. 40
Answer = B
Consider the following code segment:
first ⟵ true second ⟵ false second ⟵ first first ⟵ second
- Insert Question
A. The value of first is true, and the value of second is false. b. The value of first is false, and the value of second is true. c. The value of first is true, and the value of second is true. d. The value of first is false, and the value of second is false.
Answer = C
- Consider the following code segment:
a ⟵ 10 b ⟵ 20 c ⟵ 30 d ⟵ 40 x ⟵ 20 b ⟵ x + b a ⟵ x + 1 d ⟵ c / d + 2 DISPLAY(a)
DISPLAY(b)
DISPLAY(c)
DISPLAY(d)
- What is displayed as a result of executing the code segment?
A. 21 40 30 50 b. 10 20 30 40 c. 21 40 30 40 d. 21 30 40 50
Answer = A
My practice Problems
- a ⟵ 19 a ⟵ b a ⟵ 3 Display(b)
Answer = ?
- a ⟵ 99 a ⟵ b a ⟵ 4 c ⟵ 13 a ⟵ c Display(c)
Answer = ?
- a ⟵ 9 a ⟵ c a ⟵ 8 c ⟵ 13 a ⟵ b Display(b)
Answer = ?
- a ⟵ 18 b ⟵ a a ⟵ 11 c ⟵ 00 a ⟵ c Display(A)
Answer = ?
- a ⟵ 1 a ⟵ b a ⟵ 30 c ⟵ 15 a ⟵ c D ⟵ 44 Display(D)
Answer = ?
- a ⟵ 1 a ⟵ b a ⟵ 30 c ⟵ 15 a ⟵ c D ⟵ 44 D ⟵ b Display(B)
Answer = ?