An unrestricted use of the "go to" statement is harmful because of which of the following reason (s):
View worked solution
Answer: A
The correct option is A.
The classic argument against the unrestricted use of the goto statement was famously articulated by Edsger W. Dijkstra in his 1968 paper, "Go To Statement Considered Harmful".
Why is unrestricted goto harmful?
- Difficulty in Verification: In structured programming, the static structure of the program text closely mirrors its dynamic execution. This allows us to reason about the program's state at any point using formal verification techniques (such as loop invariants and Hoare logic). Unrestricted
gotostatements create "spaghetti code," making the dynamic execution path unpredictable and making formal verification extremely difficult.
Why other options are incorrect:
- Option B:
gotostatements do not inherently make programs inefficient. In fact, at the machine level, all control flows (loops, conditionals) are implemented using jump instructions (which are equivalent togoto). - Option C: While spaghetti code does make modification harder, the fundamental theoretical reason why computer scientists sought to eliminate
gotowas the inability to formally prove and verify program correctness. - Option D: Compilers translate
gotostatements directly into low-level jump instructions, which does not necessarily result in longer machine code.
Free practice · Your answers on this page are not saved.
