We use the goto statement to get control at a specific point in a program. After we label the identifier we can send the control to backward or forward with the use of goto statement in the program, for that we have to use semicolon at the end. We have to keep the goto statement in condition so that it won't go to loop. The basic syntax of a goto statement is given below:
Forward goto statement syntax
goto label;
….. // skip this line
….. // skip this line
…. // skip this line
label;
Statements;
…..
…..
Backward goto statement syntax
label;
statements;
….
….
…
goto label;
Flowchart
Program
QUESTION:- goto statement to find even or odd number.
output
enter a number: 7
odd!
do you want to exit?: n
enter a number: 9
odd!
do you want to exit?: y
program execute!
0 Comments