Should Programmers be able to use “GO TO” statements as they please? Some progra
ID: 3744238 • Letter: S
Question
Should Programmers be able to use “GO TO” statements as they please?
Some programming languages require that a loop only have one way in, and one way out; there are no “GO TO” statements. Other languages (like BASIC and FORTRAN) allow for statements to have “labels”, or addresses, that another statement like a GO TO can explicitly transfer control.
Discussion: What do you see as the strengths and weaknesses of each of these approaches? Would you rather work in a strongly disciplined language, that only lets you exit your loops by “falling out the bottom of them” when their control variable or interaction conditions say “I’ve had enough?” Do GO TO statements appeal to you?
Additionally, what special hazards might the programmer find when starting to combine IF, CASE, or other conditional logic on top of or inside of their loops?
Explanation / Answer
Syntax goto:
goto label_ABC;
statement 1;
statement 2;
.
.
.
label_ABC:
statement n;
In above syntax the execution of goto statement the control jump unconditionally from there to statement-n which is prefixed by the label_ABC, without executing in between statements.
types of Goto statement
1. Forward jump
2. Backward jump
Disadvantages:
1) making the program logic complex to understand
2 ) difficult to trace the control flow of a program
Insted of goto statement we use while ,if else ,for in our programing because its asy to understand , easily trace the control flow of the program.So try to avoid to use goto statement in our program.