Objective Assessment Review | Full Questions,
Correct Answers, and Worked Solutions | Latest
2026/2027 Update | 100% Correct.
Question:
1.4.3: If-else-statement i,-
1)
What is the value of abs after the following lines of code are run?
i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,-
x := 2i,- i,- i,-
If ( x > 0 )
i,- i,- i,- i,- i,- i,-
i,- abs := x i,- i,- i,-
Else abs := -x i,- i,- i,- i,-
End-if?
Answer:
2
The condition ( x > 0 ) evaluates to true because the value of x is 2. The
i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,-
line abs := x is executed and the line abs := -x is skipped. Therefore the
i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,-
final value of abs is 2.
i,- i,- i,- i,- i,-
Question:
,1.4.3: If-else-statement i,-
2)
What is the value of abs after the following lines of code are run?
i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,-
x := -2
i,- i,- i,-
If ( x > 0 )
i,- i,- i,- i,- i,- i,-
i,- abs := x i,- i,- i,-
Else i,-
i,- abs := -x i,- i,- i,-
End-if?
Answer:
2
The condition ( x > 0 ) evaluates to false because the value of x is -2. The
i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,-
line abs := x is skipped and the line abs := -x is executed. Therefore the
i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,-
final value of abs is -x, which is -(-2) = 2.
i,- i,- i,- i,- i,- i,- i,- i,- i,- i,-
Question:
1.5.2: For-loops i,-
Consider the following pseudocode fragment: i,- i,- i,- i,-
sum := 0 i,- i,-
For i = 2 to 5
i,- i,- i,- i,- i,-
,i,- sum := sum + ii,- i,- i,- i,-
End-for
1) What is the value of sum after the second iteration?
i,- i,- i,- i,- i,- i,- i,- i,- i,- i,-
2) How many iterations will the for-loop execute?
i,- i,- i,- i,- i,- i,- i,-
3) What is the final value for sum after executing the for-loop??
i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,-
Answer:
1) 5 i,-
In the first iteration, i = 2. In the second iteration, i = 3. 2 + 3 = 5
i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,-
2) 4 i,-
i = 2, 3, 4, 5. Four iterations
i,- i,- i,- i,- i,- i,- i,-
3) 14 i,-
i = 2, 3, 4, 5. sum = 2 + 3 + 4 + 5
i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,-
Question:
1.6.2: While-loops i,-
product := 1 i,- i,-
, count := 5 i,- i,-
While ( count > 0 )
i,- i,- i,- i,- i,-
i,- product := product⋅count i,- i,-
i,- count := count - 2
i,- i,- i,- i,-
End-while
1) What is the value of product after the second iteration?
i,- i,- i,- i,- i,- i,- i,- i,- i,- i,-
2) How many iterations will the while-loop execute?
i,- i,- i,- i,- i,- i,- i,-
3) What is the final value for product??
i,- i,- i,- i,- i,- i,- i,-
Answer:
1) 15 i,-
In the first iteration, count = 5. In the second iteration, count = 3. 5⋅3 = 15
i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,- i,-
2) 3 i,-
count = 5, 3, 1. Three iterations
i,- i,- i,- i,- i,- i,-
3) 15 i,-
product = 5⋅3⋅1 = 15 i,- i,- i,- i,-
Question: