Hello and welcome to the 27th tutorial in the c++ programming series and in this part we're going to look at the go to statement, the go to stimulate you to jump to anywhere in the application code. It is an extremely powerful feature but should not be used if net should be only use or if necessary, admits you can cause application errors, preferably unit within the same block of code as shown in the example that we are going to implement. So let's go ahead and open up our project if you're on Windows, Visual Studio or the text editor or what what have you feel comfortable to understand I'm not sure what we're going to do together there's a second creative very book or I assign it the value can and what we're going to put is go to statement and did this isn't how you put it, go to zero and declare you Don't have to put this particular keyword, they just put a keyword that doesn't exist in c++, and then you put a colon at the end.
That's it and that this is a statement that you can go to, you could call lists. Hulu Netflix statement according to Hulu, Netflix daymond so Hulu, Netflix daymond john into st dc, doo doo commerce base, semi colon and do it minus minus, then we're gonna do a condition and do if i is greater than zero. Then we want to jump to the Netflix statement. And the key word for go to is literally go to then you put the label aka Hulu Netflix statements that you do to Lou Net Flix. semicolon at the end with a STD c out forward slash. So this is on a new line for finished pre all in uppercase actually has to emphasize that it has finished f t d and loin.
Now, if we run it, we have 10 987654321 for lesson launch, but yeah, it's it's finished. And what we've essentially done is sort of created a loop. Obviously, you don't have to create a loop. But this is just to illustrate how it works. So we have a variable called ID declared and then we put our label here this is what it is a go to label, print out the variable then we decorate h x is the variable greater than zero so you'll just keep jumping back to the Hulu Netflix demo so for like a new and they literally it days when you go to stamina it's like really really simple as you can see right there. In the next part of the series we'll be looking at a switch statement if you have any questions feel free to message us support us on our systems Dakota UK.
The email will be in the description you can comment on this video this directly messages while you do whatever you feel comfortable with is a Okay, or they're calling for source code will also be in the description. And as usual, thanks for watching and I hope you have a nice day.