ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 29 - CTAL-TTA discussion

Report
Export

Consider the pseudo code for the Price program:

Which of the following statements about the Price program describes a control flow anomaly to be found in the program?

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

Explanation:

The pseudo code provided for the Price program shows a potential for an infinite loop due to the way the 'Del_Charge' variable is being manipulated. The loop is set to continue 'WHILE Del_Charge > 0', and within the loop, 'Del_Charge' is initially set to 5 and then potentially decreased by 2 if 'Sale_Value > 60000'. However, at the end of each loop iteration, 'Del_Charge' is increased by 1. This means that if 'Sale_Value' is not greater than 60000, 'Del_Charge' will not decrease and will instead increment indefinitely, causing an infinite loop. Even if 'Sale_Value' is greater than 60000, the decrement by 2 could be negated by the subsequent increments if the loop runs enough times, potentially leading to an infinite loop situation. There is no guaranteed exit condition once the loop is entered, which is a control flow anomaly.

asked 18/09/2024
juan manuel torrado
34 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first