In software, what statement is often associated with producing spaghetti code?

The story behind the answer

The goto statement is often associated with producing spaghetti code.

A goto statement transfers program control directly to a labeled location elsewhere in the source code. When many jumps crisscross a program, the execution path can become tangled and difficult to follow—hence the comparison with strands of spaghetti. Such code is often hard to test, debug, modify, and maintain.

The criticism became especially influential during the structured-programming movement of the 1960s and 1970s. Structured programming favored sequence, selection, and iteration constructs such as loops and conditional blocks, reducing the need for unrestricted jumps. Edsger Dijkstra’s famous 1968 letter, “Go To Statement Considered Harmful,” helped make the debate widely known.

Goto is not automatically wrong. Some languages and programmers still use it for narrowly defined tasks, such as cleanup paths or breaking out of nested logic. The quiz association concerns uncontrolled or excessive use, which can produce convoluted control flow—not every individual goto statement.

Source: Wikipedia · fact-checked Sept. 2026

Add question to a list

Choose a list to keep this question in: