1
00:00:02,310 --> 00:00:03,870
Hey, guys, what's up?

2
00:00:04,560 --> 00:00:08,100
So in last video, we discussed about global variables.

3
00:00:10,760 --> 00:00:15,650
So just like global variables, we can also make our Eddie Global.

4
00:00:16,160 --> 00:00:17,860
So what we will do, we will, right.

5
00:00:18,590 --> 00:00:23,670
And Eddie, globally, and let's say the size of global ad is 10.

6
00:00:24,950 --> 00:00:32,870
And then you can write in domain and then you can access, for example, it out of one question.

7
00:00:33,560 --> 00:00:34,310
See out.

8
00:00:36,000 --> 00:00:38,160
Eight out of five.

9
00:00:39,930 --> 00:00:41,700
So a lot of Israeli will be benter.

10
00:00:43,560 --> 00:00:44,160
And John.

11
00:00:44,850 --> 00:00:47,060
OK, so we can also create global.

12
00:00:48,280 --> 00:00:51,580
Any and we can access any like this.

13
00:00:52,530 --> 00:00:52,770
OK?

14
00:00:54,020 --> 00:01:01,070
So just like ridded and X equals 10 and we excessed here, X equals X equals 20.

15
00:01:01,610 --> 00:01:03,700
And then we have rendered the value of X.

16
00:01:04,340 --> 00:01:09,410
So just like global variables, we also have global eddys.

17
00:01:11,560 --> 00:01:13,810
OK, so let us.

18
00:01:14,980 --> 00:01:16,030
So what I will do now.

19
00:01:16,270 --> 00:01:17,950
I will write a code.

20
00:01:18,550 --> 00:01:21,820
And do you have to tell me what will be the correct output?

21
00:01:23,530 --> 00:01:27,820
So let's name this file as variable exercise.

22
00:01:31,340 --> 00:01:34,430
Variable, let's call it global variable exercise.

23
00:01:37,100 --> 00:01:38,150
Global variable.

24
00:01:39,320 --> 00:01:40,130
Exercise.

25
00:01:43,210 --> 00:01:44,260
Not CBB.

26
00:01:49,910 --> 00:01:51,950
So now I will write some code.

27
00:01:53,360 --> 00:01:54,600
And do you have to tell me?

28
00:01:54,950 --> 00:01:55,810
Correct output.

29
00:02:00,590 --> 00:02:04,640
So let us create a global variable.

30
00:02:13,660 --> 00:02:19,930
So X equals well and X equals 10.

31
00:02:22,580 --> 00:02:30,220
And I for and for I equals zero I.

32
00:02:30,400 --> 00:02:31,770
Less than five.

33
00:02:32,390 --> 00:02:35,900
A plus plus X equals.

34
00:02:36,890 --> 00:02:41,300
I see out X.

35
00:03:20,290 --> 00:03:23,020
OK, so so this is my computer code.

36
00:03:23,200 --> 00:03:25,740
You have to tell me what the leeway output.

37
00:03:26,410 --> 00:03:31,230
So what you can do is you can use a pen and paper and a bright and your code.

38
00:03:31,360 --> 00:03:36,220
OK, so you have to brighten this code on pen and paper and post the video.

39
00:03:37,270 --> 00:03:37,600
So.

40
00:03:40,340 --> 00:03:42,230
Let's see where really output.

41
00:03:43,920 --> 00:03:45,240
So it begs the question.

42
00:03:45,480 --> 00:03:50,490
So I'm writing out prettier, so initially X equals 10.

43
00:03:50,580 --> 00:03:52,850
OK, so X becomes well.

44
00:03:53,550 --> 00:03:59,970
So at lane number eight, come by level no choice error Y because compiler combined from top to bottom.

45
00:04:00,270 --> 00:04:02,280
And it knows that their line number four.

46
00:04:03,810 --> 00:04:08,760
There is a variable called X, so the value of exchange is to do.

47
00:04:09,890 --> 00:04:15,800
Now, I have created a little variable X and line number nine MEDCOM by level in our choice area, because

48
00:04:15,860 --> 00:04:20,900
this X is a local variable and this X is a global variable.

49
00:04:21,950 --> 00:04:23,970
So value of this X is then.

50
00:04:24,180 --> 00:04:28,020
OK, now allocated and other local variable called I.

51
00:04:28,490 --> 00:04:32,090
And now I am ideating I equals zero a less than five a plus plus.

52
00:04:32,630 --> 00:04:33,880
So X equals A.

53
00:04:34,700 --> 00:04:35,450
So vich X.

54
00:04:36,640 --> 00:04:37,610
Global and local.

55
00:04:38,500 --> 00:04:39,570
So local.

56
00:04:40,180 --> 00:04:40,510
Why?

57
00:04:40,870 --> 00:04:42,150
Because if I not right.

58
00:04:42,220 --> 00:04:46,690
Scope resolution operator then it will be treated as local variable.

59
00:04:47,440 --> 00:04:49,030
So local variable initially was 10.

60
00:04:49,120 --> 00:04:51,160
Now it is I which is zero.

61
00:04:51,970 --> 00:04:54,900
So see out X, which is zero.

62
00:04:56,290 --> 00:05:01,810
Then, so now I am bringing global variable, which is 20.

63
00:05:03,460 --> 00:05:08,800
Now, the value of I will be incremented, so X equals a one then.

64
00:05:10,060 --> 00:05:13,850
Then two, then again to all three.

65
00:05:15,060 --> 00:05:20,980
Well, for now, the value of I will become five equals five.

66
00:05:21,040 --> 00:05:22,720
And this loop will terminate.

67
00:05:23,470 --> 00:05:26,040
So I will reach line number 17.

68
00:05:27,120 --> 00:05:29,140
So you out really of Xs.

69
00:05:29,920 --> 00:05:34,210
So value of X is.

70
00:05:34,480 --> 00:05:37,810
So it is the value of X, the value of fixes for.

71
00:05:39,020 --> 00:05:40,540
So for every printer.

72
00:05:41,180 --> 00:05:43,580
So this X is a local variable.

73
00:05:46,030 --> 00:05:47,830
OK, so will your fixes for.

74
00:05:48,460 --> 00:05:53,950
And now I am incrementing the will of global variable by two, so it becomes 14.

75
00:05:55,380 --> 00:06:00,660
See outwardly of global eggs, so value of.

76
00:06:02,550 --> 00:06:08,000
Global X is 14 now see out.

77
00:06:08,140 --> 00:06:15,990
I so compiler will not give us error because headline number eleven I have declared my variable I and

78
00:06:15,990 --> 00:06:20,430
the scope of variability as between this and this.

79
00:06:20,670 --> 00:06:22,790
So it will not show us error.

80
00:06:23,640 --> 00:06:24,660
So what is the difference?

81
00:06:24,840 --> 00:06:25,230
What is there?

82
00:06:25,230 --> 00:06:31,770
Different thing that I do here is I used to write for error and I equals zero.

83
00:06:32,220 --> 00:06:33,120
I less than five.

84
00:06:33,570 --> 00:06:40,240
So if I write something like this then this I belong to for loop.

85
00:06:40,740 --> 00:06:44,480
So this I belongs to for loop and it Scorpio's this.

86
00:06:45,990 --> 00:06:48,420
But here I have written I.

87
00:06:49,770 --> 00:06:51,420
In main function.

88
00:06:51,510 --> 00:06:59,010
So my scope is this and this, so hard line number 22 may come by level, not show its error.

89
00:06:59,490 --> 00:07:02,720
And what is the value of I so value if I is five.

90
00:07:02,880 --> 00:07:03,540
How five?

91
00:07:03,930 --> 00:07:05,790
Because when the value of five becomes five.

92
00:07:05,850 --> 00:07:08,970
This loop got Terminator Savelli off.

93
00:07:08,970 --> 00:07:09,660
I use five.

94
00:07:10,260 --> 00:07:11,750
So this will be my output.

95
00:07:17,720 --> 00:07:21,230
OK, so let us see whether I have generated the correct output or not.

96
00:07:22,400 --> 00:07:28,330
So zero one, two, three four four 14, five zero one two, three, four four four.

97
00:07:28,340 --> 00:07:29,000
Dignon five.

98
00:07:29,100 --> 00:07:29,420
Okay.

99
00:07:33,210 --> 00:07:36,990
So zero, one, two, three, four, four, 14 and five.

100
00:07:37,880 --> 00:07:38,200
Okay.

101
00:07:38,700 --> 00:07:41,430
So I think I have generated the correct output.

102
00:07:41,880 --> 00:07:45,600
So if I have also generated this output, then congratulation.

103
00:07:45,620 --> 00:07:47,880
You have understood the topic very thoroughly.

104
00:07:49,690 --> 00:07:50,150
OK, guys.

105
00:07:50,250 --> 00:07:51,540
So this is it for this video.

106
00:07:51,690 --> 00:07:52,170
Thank you.
