CTAL-TTA practice question 16 of 25

Consider the following pseudocode segment: set a = 1 while a < 12 display “this is loop", a if a > 10 then display "loop is > 10’ set a = 5 else display “loop is < 11* endif end while display “Final value of a is", a Which of the following issues should be detected in the code review?

Full set: 174 questions
Answer options
A: Loop termination is not achievable Correct answer
B: Rounding errors on the loop counters could cause problems
C: Variables are used before they are initialized
D: Some of the code could be moved to re-usable functions
Correct Answer:
A. Loop termination is not achievable
Explanation

In the provided pseudocode, the variable a is initialized to 1. The loop condition checks if a 10. Since a starts at 1, the else branch executes, which merely displays a message without modifying the value of a. Because a is never incremented or updated during iterations where a <= 10, a remains 1 indefinitely. The loop condition a < 12 will continuously evaluate to true, creating an infinite loop. Therefore, loop termination is unachievable, which is a structural defect that must be identified during code review.

Why Incorrect

B: The variable a is an integer counter, so floating-point rounding errors cannot occur in this logic. C: The variable a is explicitly initialized (set a = 1) before it is evaluated in the loop condition. D: While refactoring is possible, moving short logic into functions does not address the core execution bug present.

References

- ISTQB Certified Tester Advanced Level Technical Test Analyst Syllabus (v3.0), Section 3.2 "Static Analysis: Control Flow Analysis".

- IEEE 1028-2008 Standard for Software Reviews and Audits, Section 6 "Code Reviews".

Scroll to Top