Hello and welcome to go down to the academy language course in the preview session, we talked about
continuous statements and indecision.
We want to talk about the others controversial statements.
Go to a statement to go to your statement and go programming language channel wise and unconditional
jump from the Go two to a labelled the statement in the same function.
Use of go to a statement is highly discouraged in any programming language because it becomes difficult
to trace the comfort flow of the program, making the program difficult to understand and modify any
program that uses a go to can be written using some other construct.
Now you can see the syntax
here.
Label can be any plain text except go keyword, and it can be set anywhere and go program above or below
to go to a statement.
Now let's go to this school with Cary Grant to illustrate how to use love, go to a statement.
First, define a variable named X and initialize it by zero values, so we write that X by the tight
end and initialize it by zero value, create a loop that works as a y loop and define the condition
and programmable continues as long as the value of X is less than eight and print value of X variable
and then add one unique to X variable.
Now do the following.
First, define a label like labor long labor while column and go to the next line and define a value
loop, so write for and set conditions.
In this case, it's less than eight or 10 in curly braces.
And write our statement here.
Now define our if luck solved right each.
For example, it's equal, equal five cities statement for this.
If like, for example, an X equals X plus one and now using go to statements, all right.
Go to label one.
And now go out of each block and displayed the very and sort of write f f value of X column first,
then d back in and said, expand it.
And in the next line, E-Trade, our biggest variable, one by one, all of Ryan Giggs plus plus okay,
in four block, we define and if plug in set, if it's equally equal, five value add one value two
x and go to two the label one position and continue the program.
OK, leave for medical, save the project and execute the program.
So go to terminal and run the program by the comment.
Go from thought back to made that go.
OK, now we can see the output value of X is zero one two three four six seven.
And we can see the value of X equals five.
The program runs and it's time first place the value of the X variable and then adds one unit to the
variable X until the value of X equals five.
In this case, the program enters the FBI and executes the commands inside the block and adds one units
to east and jumps from one reputation and skips the value five and then go to the first of loop and
check the value of X and continue.
So we could define go to a statement.
We have reached end of decision.
I hope you take full advantage of this session until next edition.
Goodbye.