ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 3 - CTAL-TTA discussion

Report
Export

Consider the pseudo code for the Answer program:

Which of the following statements about the Answer program BEST describes the control flow anomalies to be found in the program?

A.
The Answer program contains no control flow anomalies.
Answers
A.
The Answer program contains no control flow anomalies.
B.
The Answer program contains unreachable code.
Answers
B.
The Answer program contains unreachable code.
C.
The Answer program contains unreachable code and an infinite loop.
Answers
C.
The Answer program contains unreachable code and an infinite loop.
D.
The Answer program contains an infinite loop.
Answers
D.
The Answer program contains an infinite loop.
Suggested answer: C

Explanation:

The provided pseudo code for the Answer program shows a WHILE loop that will always execute because the condition for the loop to terminate (a >= d) is never met within the loop's body. This results in an infinite loop. Additionally, since the value of 'b' is initialized with 'a + 10' and 'a' starts from a value that is read and then set to 2, 'b' will never be equal to 12. Therefore, the 'THEN' branch of the IF statement, which includes 'print(b)', is unreachable. These are control flow anomalies because they represent logic in the code that will not function as presumably intended.

asked 18/09/2024
Tarnauceanu Diana
40 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first