Question 1 of 10
A program executes the assignments below in order.
x ← 4
y ← 9
x ← y
DISPLAY (x)
What is displayed?
- A. 9
- B. 13
- C. Nothing is displayed.
- D. 4
A program executes the assignments below in order.
x ← 4
y ← 9
x ← y
DISPLAY (x)
What is displayed?
After the segment below runs, which pair of values is stored?
a ← 2
b ← 5
a ← a + 1
b ← a
A student wants to swap the values in p and q. Which attempt correctly swaps them?
| Attempt | Code |
|---|---|
| 1 | p ← q then q ← p |
| 2 | temp ← p then p ← q then q ← temp |
| 3 | p ← p then q ← q |
| 4 | q ← p then p ← q |
Consider the segment below.
m ← 7
n ← 3
m ← n
n ← m
DISPLAY (m)
DISPLAY (n)
What is displayed, in order?
The assignments below run in order. What are the final values of x and y?
x ← 1
y ← 2
x ← x + y
y ← x - y
x ← x - y
Which statement about assignment is accurate?
What does the following segment display?
score ← 10
bonus ← 4
score ← score + bonus
bonus ← 0
DISPLAY (score)
A robot stores two sensor readings in left and right. A programmer runs:
left ← 8
right ← 5
temp ← left
left ← right
right ← temp
Which statement is true afterward?
After these assignments, what is the value of total?
a ← 6
b ← 2
c ← 1
total ← a
total ← total + b
total ← total + c
Which sequence leaves first holding the original value of second and second holding the original value of first?