1
00:00:02,580 --> 00:00:04,350
Hey, guys, what's up?

2
00:00:04,890 --> 00:00:09,030
So in this video, we will learn a new concept called By Value.

3
00:00:10,980 --> 00:00:13,920
So it is very important, so pay attention.

4
00:00:15,130 --> 00:00:18,250
So we'll try to understand this concept with the help of an example.

5
00:00:18,820 --> 00:00:22,690
So suppose my question is right to function.

6
00:00:23,500 --> 00:00:24,790
We have to write a function.

7
00:00:26,010 --> 00:00:28,800
To slap two numbers.

8
00:00:31,290 --> 00:00:35,310
OK, so our aim is to write a function to slap two numbers.

9
00:00:36,510 --> 00:00:37,590
So let us write the code.

10
00:00:38,130 --> 00:00:38,670
So.

11
00:00:39,800 --> 00:00:45,210
Void that isn't able to function will be void because it is not going to return anything.

12
00:00:45,930 --> 00:00:48,080
Let's say the name of the function is my SEP.

13
00:00:49,880 --> 00:00:52,670
And I am digging to numbers as input.

14
00:00:54,960 --> 00:01:04,650
And how does that two numbers, so them, because A equals B and B equals temp.

15
00:01:07,330 --> 00:01:07,590
OK.

16
00:01:07,760 --> 00:01:15,380
So they we lose the slabbed and let's say I'm calling this function from mean, so Intiman led to the

17
00:01:15,380 --> 00:01:20,000
value of is five and the value of B is seven.

18
00:01:20,780 --> 00:01:22,880
And I'm calling function my step.

19
00:01:23,000 --> 00:01:25,070
So my SPREP.

20
00:01:27,890 --> 00:01:29,370
A and B is input.

21
00:01:30,270 --> 00:01:34,410
Now let us burn the valley off A and B.

22
00:01:36,790 --> 00:01:37,840
So what do you think?

23
00:01:38,020 --> 00:01:39,050
Where do live my output?

24
00:01:40,750 --> 00:01:41,920
So I believe it should happen.

25
00:01:41,980 --> 00:01:44,260
The value of NDB should be swept.

26
00:01:44,860 --> 00:01:49,780
So if the value of is five, the new video feature becomes seven.

27
00:01:50,110 --> 00:01:57,010
If the value of BES seven, the new value of B should become five so badly, they should be more output.

28
00:01:58,690 --> 00:02:01,950
Now, let's see what will be my output.

29
00:02:04,120 --> 00:02:06,790
So I am naming this file as called by value.

30
00:02:25,540 --> 00:02:29,510
Now, let's say that doing a Mozart and a quiz.

31
00:02:29,580 --> 00:02:35,800
So An and and B equals five.

32
00:02:36,460 --> 00:02:38,200
So these are the two numbers.

33
00:02:39,130 --> 00:02:41,830
And let's to the name of the function is my step.

34
00:02:43,960 --> 00:02:46,960
And I will give A and B as input.

35
00:02:48,550 --> 00:02:48,850
OK.

36
00:02:50,050 --> 00:02:52,370
Now let us write code for swapping.

37
00:02:53,350 --> 00:02:56,500
So avoid my ASVAB.

38
00:02:59,520 --> 00:03:06,750
It will take two numbers as input and then we will write those three magical lines.

39
00:03:07,600 --> 00:03:13,800
So and --, because A A equals B.

40
00:03:15,970 --> 00:03:18,160
And B equals temp.

41
00:03:19,300 --> 00:03:25,330
So with the help of these three magical lines, the village of NDB will be swept.

42
00:03:26,410 --> 00:03:26,700
OK.

43
00:03:27,280 --> 00:03:29,690
So let us try to bend the values of NDB.

44
00:03:30,520 --> 00:03:32,410
So before swapping C out.

45
00:03:34,420 --> 00:03:36,700
Before stepping.

46
00:03:39,060 --> 00:03:43,460
So before slapping the value of let's spend the value of NDB.

47
00:03:51,960 --> 00:03:54,960
And also, let us rent the video, Flanby after sipping.

48
00:03:59,950 --> 00:04:01,420
So after sipping.

49
00:04:04,900 --> 00:04:06,610
So this is my entire record.

50
00:04:07,750 --> 00:04:09,250
Let's see where the live output.

51
00:04:12,440 --> 00:04:13,360
Before Sepi.

52
00:04:13,460 --> 00:04:13,950
OK.

53
00:04:35,450 --> 00:04:37,640
So before supping, we lose our seven and five.

54
00:04:37,670 --> 00:04:41,270
And after sipping again, the values are seven and five.

55
00:04:41,750 --> 00:04:44,480
So the values are not getting swept.

56
00:04:46,920 --> 00:04:53,200
Now, let us spend here the values of sources out in function.

57
00:04:56,640 --> 00:04:58,680
Now in a desert in the valley of a be here.

58
00:04:58,890 --> 00:05:01,020
And let's see where the values are getting Sabga.

59
00:05:01,060 --> 00:05:02,910
Not so easy out.

60
00:05:11,680 --> 00:05:18,620
And similarly, let us also, Brent, before stepping so.

61
00:05:28,250 --> 00:05:33,250
So in function, let's call it before before stepping.

62
00:05:33,350 --> 00:05:33,660
OK?

63
00:05:34,580 --> 00:05:36,380
And let's call it after stepping.

64
00:05:37,880 --> 00:05:42,760
So let's see whether my whether there is an issue with Mizer function or not.

65
00:05:46,880 --> 00:05:50,060
So before stepping so in faith, these were the initial values here.

66
00:05:50,660 --> 00:05:51,800
Now I'm in function.

67
00:05:52,250 --> 00:05:56,840
So before stepping the religion, so in fact, the seven and five correct after seven, that we lose

68
00:05:56,840 --> 00:05:57,830
our faith in seven.

69
00:05:58,400 --> 00:06:01,670
Then how these values become seven and five.

70
00:06:01,730 --> 00:06:04,010
As soon as I add each mean function.

71
00:06:05,330 --> 00:06:06,220
So justice again.

72
00:06:06,350 --> 00:06:08,080
Let's sprint real loose correctly.

73
00:06:08,540 --> 00:06:18,200
So before stepping in men in main function and after stepping in main function.

74
00:06:18,890 --> 00:06:19,760
Now let's see again.

75
00:06:22,370 --> 00:06:28,040
So before stepping in main function, the values are seven and five in function before slipping the

76
00:06:28,070 --> 00:06:28,370
values.

77
00:06:28,460 --> 00:06:29,590
So in five, correct.

78
00:06:30,020 --> 00:06:32,120
After stepping, will this become five and seven?

79
00:06:32,480 --> 00:06:38,660
But as soon as I reach function, mean the values become seven and five again.

80
00:06:39,740 --> 00:06:43,380
So basically there is no effect of stepping back by.

81
00:06:46,120 --> 00:06:48,070
So let me show you how it is happening.

82
00:06:56,400 --> 00:06:56,820
So.

83
00:06:58,380 --> 00:07:00,530
I am calling this function myself.

84
00:07:01,150 --> 00:07:02,590
So in main function.

85
00:07:04,790 --> 00:07:09,530
This is A this is B, where does the real of A seven?

86
00:07:09,590 --> 00:07:11,630
What is the value of B five?

87
00:07:12,110 --> 00:07:17,330
Then I told you that this A and this A, they both are different.

88
00:07:17,750 --> 00:07:23,240
So since they are different, they will be allocated different memory and the values are getting copied

89
00:07:23,540 --> 00:07:25,640
the way Leo Fey is getting copied.

90
00:07:26,120 --> 00:07:27,610
So a seven a.

91
00:07:30,560 --> 00:07:36,260
Similarly, this bee and this bee, they are different, only their values are getting copied.

92
00:07:37,560 --> 00:07:42,000
So five, now I am doing these kinds of stuff.

93
00:07:42,360 --> 00:07:44,030
Now this is the main part swapping.

94
00:07:44,430 --> 00:07:45,270
So what will happen?

95
00:07:45,330 --> 00:07:47,250
I will take a variable temp.

96
00:07:49,010 --> 00:07:50,390
And sipping, will they please?

97
00:07:51,800 --> 00:07:54,230
OK, so slapping will take place.

98
00:07:54,620 --> 00:07:58,520
The new belly of the new well, your fee will become five.

99
00:07:59,000 --> 00:07:59,870
And the value of.

100
00:07:59,950 --> 00:08:00,740
So this is Gosbee.

101
00:08:01,070 --> 00:08:03,440
So the value of B will become seven.

102
00:08:04,910 --> 00:08:08,840
So the values are getting swept and now I am printing the new values.

103
00:08:09,330 --> 00:08:11,500
So five and seven will get printed.

104
00:08:11,520 --> 00:08:13,260
Initial the value was seven and five.

105
00:08:13,680 --> 00:08:14,540
So this is correct.

106
00:08:16,380 --> 00:08:19,860
Now, at this point of time, this function and.

107
00:08:21,010 --> 00:08:27,400
Since this function and this whole thing goes, this whole thing is popped out of the stack.

108
00:08:27,970 --> 00:08:28,730
If you remember.

109
00:08:29,080 --> 00:08:31,630
So this whole thing is popped out of the stack.

110
00:08:32,050 --> 00:08:38,470
I will reach at this line after swiping the values of A and B are again, seven and five.

111
00:08:38,910 --> 00:08:44,260
So there is no effect of all this on the values of A and B..

112
00:08:44,350 --> 00:08:46,500
So my step function is wrong.

113
00:08:49,250 --> 00:08:54,290
OK, so this thing is called gold by value, you call by value.

114
00:08:56,320 --> 00:09:00,550
And the name is justified because we are just giving the values.

115
00:09:01,540 --> 00:09:03,520
We are just passing on the values.

116
00:09:03,580 --> 00:09:04,060
Seven.

117
00:09:04,450 --> 00:09:08,230
And similarly, we are just calling the function by values.

118
00:09:08,320 --> 00:09:09,670
We are giving values.

119
00:09:10,330 --> 00:09:10,560
OK.

120
00:09:10,840 --> 00:09:15,130
So here I was giving seven value and I was giving five value.

121
00:09:15,610 --> 00:09:18,670
So we are calling the function by value.

122
00:09:21,580 --> 00:09:23,620
Now, how we can correct our approach.

123
00:09:25,180 --> 00:09:26,680
So how to solve this problem?

124
00:09:28,270 --> 00:09:29,360
I want to do swapping.

125
00:09:29,860 --> 00:09:35,020
So how against all this problem, this we will see in the next video.

126
00:09:35,740 --> 00:09:36,070
OK.

127
00:09:36,340 --> 00:09:36,850
Thank you.
