Hey, guys, what's up?
So in last video, we discussed about global variables.
So just like global variables, we can also make our Eddie Global.
So what we will do, we will, right.
And Eddie, globally, and let's say the size of global ad is 10.
And then you can write in domain and then you can access, for example, it out of one question.
See out.
Eight out of five.
So a lot of Israeli will be benter.
And John.
OK, so we can also create global.
Any and we can access any like this.
OK?
So just like ridded and X equals 10 and we excessed here, X equals X equals 20.
And then we have rendered the value of X.
So just like global variables, we also have global eddys.
OK, so let us.
So what I will do now.
I will write a code.
And do you have to tell me what will be the correct output?
So let's name this file as variable exercise.
Variable, let's call it global variable exercise.
Global variable.
Exercise.
Not CBB.
So now I will write some code.
And do you have to tell me?
Correct output.
So let us create a global variable.
So X equals well and X equals 10.
And I for and for I equals zero I.
Less than five.
A plus plus X equals.
I see out X.
OK, so so this is my computer code.
You have to tell me what the leeway output.
So what you can do is you can use a pen and paper and a bright and your code.
OK, so you have to brighten this code on pen and paper and post the video.
So.
Let's see where really output.
So it begs the question.
So I'm writing out prettier, so initially X equals 10.
OK, so X becomes well.
So at lane number eight, come by level no choice error Y because compiler combined from top to bottom.
And it knows that their line number four.
There is a variable called X, so the value of exchange is to do.
Now, I have created a little variable X and line number nine MEDCOM by level in our choice area, because
this X is a local variable and this X is a global variable.
So value of this X is then.
OK, now allocated and other local variable called I.
And now I am ideating I equals zero a less than five a plus plus.
So X equals A.
So vich X.
Global and local.
So local.
Why?
Because if I not right.
Scope resolution operator then it will be treated as local variable.
So local variable initially was 10.
Now it is I which is zero.
So see out X, which is zero.
Then, so now I am bringing global variable, which is 20.
Now, the value of I will be incremented, so X equals a one then.
Then two, then again to all three.
Well, for now, the value of I will become five equals five.
And this loop will terminate.
So I will reach line number 17.
So you out really of Xs.
So value of X is.
So it is the value of X, the value of fixes for.
So for every printer.
So this X is a local variable.
OK, so will your fixes for.
And now I am incrementing the will of global variable by two, so it becomes 14.
See outwardly of global eggs, so value of.
Global X is 14 now see out.
I so compiler will not give us error because headline number eleven I have declared my variable I and
the scope of variability as between this and this.
So it will not show us error.
So what is the difference?
What is there?
Different thing that I do here is I used to write for error and I equals zero.
I less than five.
So if I write something like this then this I belong to for loop.
So this I belongs to for loop and it Scorpio's this.
But here I have written I.
In main function.
So my scope is this and this, so hard line number 22 may come by level, not show its error.
And what is the value of I so value if I is five.
How five?
Because when the value of five becomes five.
This loop got Terminator Savelli off.
I use five.
So this will be my output.
OK, so let us see whether I have generated the correct output or not.
So zero one, two, three four four 14, five zero one two, three, four four four.
Dignon five.
Okay.
So zero, one, two, three, four, four, 14 and five.
Okay.
So I think I have generated the correct output.
So if I have also generated this output, then congratulation.
You have understood the topic very thoroughly.
OK, guys.
So this is it for this video.
Thank you.