Which type of defect should you report as part of the code review?

You have been assigned to perform a review on code provided below:

Which type of defect should you report as part of the code review?
A . Endless loop
B . Unreachable code
C . Too many nested levels
D . No defects should be reported, code is correct.

Answer: A

Explanation:

The code provided contains a potential endless loop. The loop is conditioned on the variable ‘E’ being less than 1 (IF E < 1), but within the loop, there is no operation that modifies the value of ‘E’. Therefore, once the loop is entered, if the condition A > B holds true, the value of ‘E’ remains unchanged, leading to an endless loop situation. The decrement of ‘A’ in line 15 does not guarantee an exit condition for the loop, as it does not affect the value of ‘E’. This is a control flow defect that could cause the program to hang or crash.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments