A program needs to test whether an integer n is even. Which expression evaluates to true exactly when n is even?
n / 2 = 0n MOD 2 = 0n MOD 2 = 1n * 2 = 0
Was this exam question helpful?
A program needs to test whether an integer n is even. Which expression evaluates to true exactly when n is even?
n / 2 = 0
n MOD 2 = 0
n MOD 2 = 1
n * 2 = 0
Choose your answer
Was this exam question helpful?
A program asks the user for two numbers, adds them together, and displays the result. Which algorithm building blocks does this process use?
Sequencing only
Selection only
Sequencing and selection
Sequencing, selection, and iteration
Choose your answer
Was this exam question helpful?
Which of the following is true of all three common ways of expressing an algorithm — natural language, a flowchart, and pseudocode?
They can all describe the same algorithm; only the format differs
Only pseudocode can represent selection and iteration
A flowchart can express logic that pseudocode cannot
Natural language is the most precise of the three
Choose your answer
Was this exam question helpful?
Two programs produce identical output. Which feature most improves the readability of one version over the other?
Using meaningful variable names such as totalPrice instead of t
Writing every statement on a single long line
Removing all comments to shorten the program
Replacing variable names with single letters to save typing
Choose your answer
Was this exam question helpful?
What is the value of the following expression?
29 MOD 83
8
5
0
Choose your answer
Was this exam question helpful?
What is the value of the following expression?
7 / 23
4
1
3.5
Choose your answer
Was this exam question helpful?
Consider the following code segment.
total ← 9
count ← 2
average ← total / count
DISPLAY(average)What value is displayed when this code segment is executed?
4
5
1
4.5
Choose your answer
Was this exam question helpful?
A program needs to test whether an integer k is a multiple of 3. Which expression evaluates to true exactly when k is a multiple of 3?
k / 3 = 0
k MOD 3 = 1
k * 3 = 0
k MOD 3 = 0
Choose your answer
Was this exam question helpful?
A program repeatedly asks the user to guess a secret number. After each guess it checks whether the guess is correct, and it stops only when the guess matches the secret number. Which algorithm building blocks are used in this process?
Iteration only
Sequencing, selection, and iteration
Selection only
Sequencing and selection only
Choose your answer
Was this exam question helpful?
A program calculates a value correctly but is difficult for others to read. Which change would most improve its readability without changing the program's output?
Combining all statements onto a single line to save space
Renaming meaningful variable names to single letters
Adding a brief comment that explains a non-obvious calculation
Removing the blank lines that separate logical sections
Choose your answer
Was this exam question helpful?
What is the value of the following expression?
20 MOD 6 * 2 + 13
5
9
13
Choose your answer
Was this exam question helpful?
Which two of the following expressions evaluate to exactly 3? Select two answers.
17 MOD 7
12 / 4
10 MOD 4
7 - 5
Choose your answer
Was this exam question helpful?
Consider the following code segment.
x ← 8
y ← x / 2
x ← y + 6
y ← x - y
DISPLAY(x + y)What value is displayed?
12
14
16
20
Choose your answer
Was this exam question helpful?
What value does the following expression evaluate to?
3 + 22 MOD 5 * 411
5
0
20
Choose your answer
Was this exam question helpful?
What value does the following expression evaluate to?
(4 + 5) * 2 - 6 / 34
16
12
20
Choose your answer
Was this exam question helpful?
What value does the following expression evaluate to?
10 MOD 3 + 12 / 44
6
1
3
Choose your answer
Was this exam question helpful?
A clock stores the current hour as an integer h in the range 0 to 11. Which expression gives the hour 5 hours later, wrapping back around to 0 after 11?
h + 5 MOD 12
(h + 5) MOD 12
(h + 5) / 12
(h MOD 12) + 5
Choose your answer
Was this exam question helpful?
Consider the following code segment.
a ← 15
b ← a MOD 4
c ← a / b
DISPLAY(c)What value is displayed when this code segment is executed?
3
4
5
3.75
Choose your answer
Was this exam question helpful?
What value does the following expression evaluate to?
(6 + 9) MOD 4 * 23
6
8
30
Choose your answer
Was this exam question helpful?
Consider the following code segment.
x ← 6
x ← x * x
x ← x MOD 7
DISPLAY(x)What value is displayed when this code segment is executed?
36
5
1
6
Choose your answer
Was this exam question helpful?
What value does the following expression evaluate to?
8 + 3 * 4 MOD 5 - 19
10
3
19
Choose your answer
Was this exam question helpful?
Consider the following code segment.
p ← 20
q ← p MOD 6
r ← p / 5
s ← q * r
DISPLAY(s)What value is displayed when this code segment is executed?
8
12
0
4
Choose your answer
Was this exam question helpful?