How to use “goto”? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How to use “goto”?

Can anyone tell me how to use “goto”? By the way, what are the advantages and disadvantages of “goto”? You can take either C++ or Java for example, for I can only use these two, thank you!

9th Jan 2018, 6:01 AM
Oscar Jin
Oscar Jin - avatar
1 Answer
+ 7
ex. int i = 5; goto test; i = 0; test: i++; // i = 6 pro: quick way for jump some line of code, exit from nested loop without particular condition. con: goto makes difficult to trace the control flow of a program, making the program hard to understand and hard to modify
9th Jan 2018, 6:34 AM
AtoMX
AtoMX - avatar