ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 92 - CTAL-TTA discussion

Report
Export

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?

A.
Loop termination is not achievable
Answers
A.
Loop termination is not achievable
B.
Rounding errors on the loop counters could cause problems
Answers
B.
Rounding errors on the loop counters could cause problems
C.
Variables are used before they are initialized
Answers
C.
Variables are used before they are initialized
D.
Some of the code could be moved to re-usable functions
Answers
D.
Some of the code could be moved to re-usable functions
Suggested answer: A

Explanation:

The pseudocode provided includes a while loop that adjusts the loop variable a within the loop's conditional code block. This adjustment, set a = 5, occurs when a > 10. Because the loop checks a < 12 as its continuation condition, and a is reset to 5 repeatedly once it exceeds 10, the loop will execute indefinitely, preventing termination. This creates an infinite loop situation since the condition a < 12 will perpetually remain true once a exceeds 10. This is a critical logic error needing correction for proper execution flow.

asked 18/09/2024
B Erol
57 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first