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

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.
B . The Price program contains unreachable code.
C . The Price program contains data flow defects.
D . The Price program contains an infinite loop.

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.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments