What is wrong with using goto?

Because they lead to spaghetti code.

In the past, programming languages didn’t have while loops, if statements, etc., and programmers used goto to make up the logic of their programs. It lead to an unmaintainable mess.

That’s why the CS gods created methods, conditionals and loops. Structured programming was a revolution at the time.

goto’s are appropriate in a few places, such as for jumping out of nested loops.

Leave a Comment