ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 128 - CTAL-TTA discussion

Report
Export

You have been given this piece of pseudocode to review Assume that the variables have been declared set and validated in code that precedes this piece that you are reviewing Looking only at this part of the code what requires further discussion?

If a < b then

If a > 12 then

seta = 21

else

set a = 23

endif

If b < 17 then

set a = 24

endif

lfb> 14

set a = 25

set b = 10

else

set a = 5

endif

else

set a = 7

endif

A.
Embedded if statements should not be used
Answers
A.
Embedded if statements should not be used
B.
A variable should not be set to multiple values within one code segment
Answers
B.
A variable should not be set to multiple values within one code segment
C.
A loop should have been used rather than the embedded if statements
Answers
C.
A loop should have been used rather than the embedded if statements
D.
An else statement may be missing
Answers
D.
An else statement may be missing
Suggested answer: D

Explanation:

The pseudocode presented for review exhibits a likely issue with the control structure, particularly a missing else statement. This inference is drawn from the unbalanced opening and closing of conditional statements. The inner conditional structures suggest alternative outcomes based on several conditions, but the snippet likely misses an else statement associated with the condition lfb > 14, which could lead to ambiguous or unintended code behavior when lfb <= 14. Such issues can make the code difficult to maintain and could introduce bugs if not addressed. Ensuring each if has a corresponding else can prevent such potential errors in branching logic.

asked 18/09/2024
Maxime SELLY
43 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first