1
00:00:00,390 --> 00:00:05,640
OK, so with that, let's go ahead and move on to the next thing, I think that's kind of enough on

2
00:00:05,640 --> 00:00:05,880
that.

3
00:00:05,890 --> 00:00:06,930
It's kind of a simple topic.

4
00:00:07,350 --> 00:00:12,210
So now we move on to these assignment operators.

5
00:00:12,510 --> 00:00:15,420
So this is kind of interesting.

6
00:00:15,420 --> 00:00:22,650
We have this plus equal minus equal times equal and divided equal.

7
00:00:23,250 --> 00:00:29,100
So this is really the same thing as doing something like.

8
00:00:30,980 --> 00:00:34,610
Let's see what we have here, so we have one.

9
00:00:35,030 --> 00:00:35,900
Let's go ahead and use that.

10
00:00:35,900 --> 00:00:40,940
So if you wanted to say something like I one equals.

11
00:00:42,000 --> 00:00:45,480
I one plus two.

12
00:00:47,190 --> 00:00:50,760
Basically, this is you just wanting to update I one, right?

13
00:00:51,150 --> 00:00:54,450
So I one right here is five.

14
00:00:54,840 --> 00:01:01,800
So this is kind of the same thing as saying, OK, I one equals five plus two.

15
00:01:03,120 --> 00:01:12,780
Actually, the same thing, except that you're maybe not sure what the value is that's inside of the

16
00:01:12,780 --> 00:01:14,130
eye, one variable.

17
00:01:14,760 --> 00:01:16,680
Maybe it's five.

18
00:01:16,890 --> 00:01:18,500
Maybe it's something else.

19
00:01:18,510 --> 00:01:25,500
And so an important thing is to not try and pretend that you know what it is, because that way you

20
00:01:25,500 --> 00:01:30,360
can let it be multiple things we'll see later on that the user, often the user of the program, is

21
00:01:30,360 --> 00:01:33,960
the one that will describe what type of numerical data you're getting.

22
00:01:34,710 --> 00:01:41,430
So a good thing is just to see if you want to update one, you would just say, OK, I want i1 whatever

23
00:01:41,430 --> 00:01:44,430
it is to be two more now than it was previously.

24
00:01:44,430 --> 00:01:50,190
And that is something you can do by saying, All right, let's make I one have the value.

25
00:01:50,190 --> 00:01:53,970
So assignment operator, whatever it is, plus two.

26
00:01:55,930 --> 00:01:59,250
So now let's talk about this stuff.

27
00:01:59,320 --> 00:02:10,960
So basically, what you can do is instead you i1 plus equals two, which is essentially the same thing,

28
00:02:10,960 --> 00:02:15,100
so same as IE one equals.

29
00:02:15,610 --> 00:02:22,180
So it's basically the same as this same thing as saying I one equals one plus two.

30
00:02:22,600 --> 00:02:24,580
It's just a shorthand version of it.

31
00:02:25,270 --> 00:02:27,870
So let's go ahead and verify that.

32
00:02:27,880 --> 00:02:32,430
So I'm going to have this line right here.

33
00:02:32,440 --> 00:02:36,850
I'll actually say I want equals five to reset it in between here.

34
00:02:39,280 --> 00:02:48,220
So let me do a C out, and I'm going to say I won and C and line and then what I'm going to do is copy

35
00:02:48,220 --> 00:02:53,020
this and then we'll put it right here and then we'll put it right here.

36
00:02:53,500 --> 00:02:55,650
So we'll very well actually put it before this, too.

37
00:02:55,660 --> 00:02:58,030
So we'll verify that it starts out as five.

38
00:02:58,660 --> 00:03:04,180
Then we'll show that we add two to it and store it back into it, set into itself.

39
00:03:04,780 --> 00:03:06,970
And then we will set it back to five.

40
00:03:06,970 --> 00:03:12,610
And we'll do this this right here and show you that it has the same exact result as this one right here.

41
00:03:13,390 --> 00:03:14,980
So let's go ahead and save this.

42
00:03:15,550 --> 00:03:16,600
I'm going to compile it.

43
00:03:17,050 --> 00:03:17,890
I'm going to run it.

44
00:03:18,130 --> 00:03:19,570
And let's look at our output here.

45
00:03:22,820 --> 00:03:23,460
All right.

46
00:03:23,480 --> 00:03:29,780
So we have it's hard to get the outfit here.

47
00:03:29,870 --> 00:03:30,200
All right.

48
00:03:31,070 --> 00:03:31,940
So.

49
00:03:34,240 --> 00:03:36,790
We printed this out still, so I'm going to comment this out.

50
00:03:36,850 --> 00:03:43,330
Let's go ahead and compile this, and then again, I've actually got to save.

51
00:03:45,940 --> 00:03:49,720
So I'm I run this again and you notice that.

52
00:03:51,580 --> 00:03:53,560
We have what we kind of expect.

53
00:03:53,950 --> 00:03:58,070
So it starts out as five, because that's what it originally was.

54
00:03:58,090 --> 00:03:59,620
The variable was five of there.

55
00:04:00,130 --> 00:04:04,450
Then we add two to it and store it back into itself.

56
00:04:04,720 --> 00:04:07,210
So this becomes seven.

57
00:04:08,170 --> 00:04:11,440
Then you is what we do is we reset it to five.

58
00:04:12,190 --> 00:04:18,850
We print that out to confirm it, which is this five right here and then we do this i1 plus equals two,

59
00:04:19,660 --> 00:04:22,750
which is the same thing as saying I want equals I one plus two.

60
00:04:22,780 --> 00:04:25,390
We print it out just to confirm it has the same result.

61
00:04:25,930 --> 00:04:28,480
So really, this is just a shorthand.

62
00:04:29,590 --> 00:04:33,820
Version of this just makes it simpler, it's kind of nice cleaner.

63
00:04:34,240 --> 00:04:39,580
And it's really the same for all the operators here, so I can actually do a multiplication.

64
00:04:41,640 --> 00:04:48,690
And I'll do a multiplication here, and so this will be five times to rather than five plus two, right?

65
00:04:49,050 --> 00:04:50,940
So let's go ahead and save this.

66
00:04:51,600 --> 00:04:52,650
I'm going to compile it.

67
00:04:53,100 --> 00:04:56,330
I'm going to run it and you notice that we get what we expect to.

68
00:04:56,340 --> 00:04:59,070
So five, we multiply times.

69
00:04:59,070 --> 00:04:59,550
Two.

70
00:04:59,940 --> 00:05:02,760
We print out 10, because that's what it is.

71
00:05:03,300 --> 00:05:04,820
Then we set it back to five.

72
00:05:04,830 --> 00:05:05,760
We confirm that.

73
00:05:06,360 --> 00:05:10,890
Then we go here and we do the same thing five times.

74
00:05:10,890 --> 00:05:15,090
Two is 10 stories that back in I one printout, I won and I want us 10.

75
00:05:15,870 --> 00:05:22,830
And it's going to be the same for all these other operators as well, just using the, you know, associated

76
00:05:23,010 --> 00:05:24,060
basic operator.

77
00:05:25,650 --> 00:05:25,900
Cool.

78
00:05:25,950 --> 00:05:27,150
So pretty interesting.

79
00:05:29,740 --> 00:05:32,610
Once again, I'm going to go ahead and kind of comment this out.

80
00:05:33,630 --> 00:05:35,370
You can leave them if you want.

81
00:05:38,240 --> 00:05:38,630
What's?

82
00:05:42,770 --> 00:05:43,130
All right.

83
00:05:43,310 --> 00:05:50,870
So now I'm going to talk about something kind of cool and interesting, which are the plus plus and

84
00:05:50,870 --> 00:05:54,110
minus minus operators, I actually need to change this.

85
00:05:54,140 --> 00:05:57,590
This is actually something called fixed, so we'll talk about that too.

86
00:05:58,970 --> 00:06:03,860
So what I'm going to do now is, let's say I want to.

87
00:06:05,040 --> 00:06:10,170
Just add one to a variable, so I want to increment it in my increment.

88
00:06:10,260 --> 00:06:12,100
I just mean moving up by one.

89
00:06:12,120 --> 00:06:13,500
So add one to something.

90
00:06:13,500 --> 00:06:15,510
So it would be something like this.

91
00:06:15,510 --> 00:06:17,670
I want equals I one plus one.

92
00:06:19,910 --> 00:06:25,580
Something like that, or if I want to subtract one, it would be like I one equals one minus one.

93
00:06:26,390 --> 00:06:29,900
And we already just talked about the fact that this can be simplified, right?

94
00:06:30,260 --> 00:06:33,620
It's going to be simplified to A1 plus equals one.

95
00:06:34,310 --> 00:06:41,000
And this basically can be simplified to A1 one minus equals one.

96
00:06:41,030 --> 00:06:41,330
Right?

97
00:06:42,980 --> 00:06:50,480
So something even simpler if we're dealing with just one wanting to add or subtract one from a variable,

98
00:06:50,870 --> 00:06:57,440
we can actually do something like plus plus I i1 and minus minus A1.

99
00:06:58,220 --> 00:07:01,190
So those essentially do the same thing.

100
00:07:01,550 --> 00:07:06,530
So I can say A1 five to reset it here.

101
00:07:07,100 --> 00:07:09,350
I will say one five.

102
00:07:12,060 --> 00:07:13,860
I one equals five.

103
00:07:15,240 --> 00:07:20,100
So let's go ahead and just print this out to show that it's the same thing.

104
00:07:20,640 --> 00:07:23,300
So I do sneak out.

105
00:07:23,330 --> 00:07:23,970
I won

106
00:07:26,370 --> 00:07:27,270
and.

107
00:07:29,090 --> 00:07:34,370
I'll go ahead and just put it here, we know that we're resetting it to five, right?

108
00:07:34,370 --> 00:07:37,760
So I'm not going to like show that this time.

109
00:07:39,980 --> 00:07:46,670
But now we print it out and we should see that on the bottom to should correspond with the top two.

110
00:07:47,420 --> 00:07:48,290
So I save it.

111
00:07:48,710 --> 00:07:51,020
I compile it, I run it.

112
00:07:51,920 --> 00:07:52,650
And it does.

113
00:07:52,670 --> 00:07:55,760
You notice we have a fix to start out with.

114
00:07:55,760 --> 00:07:57,830
So I won was five.

115
00:07:58,310 --> 00:08:00,980
And then what we did was we added one to it.

116
00:08:00,980 --> 00:08:03,200
So we said i1 equals one plus one.

117
00:08:04,310 --> 00:08:09,530
And, you know, this is also the shorthand we could have just used that as well because I just talk

118
00:08:09,540 --> 00:08:10,220
to you about that.

119
00:08:10,790 --> 00:08:11,600
So I printed that out.

120
00:08:11,600 --> 00:08:12,230
It was six.

121
00:08:12,240 --> 00:08:13,400
We reset to five.

122
00:08:13,700 --> 00:08:16,890
We did a little minus and that was four.

123
00:08:17,000 --> 00:08:17,390
Right.

124
00:08:17,840 --> 00:08:19,970
So we said to five minus one was four.

125
00:08:20,870 --> 00:08:23,810
Then we we said to five and we did a plus.

126
00:08:23,810 --> 00:08:28,450
Plus you notice that increment did it to six and then we reset to five.

127
00:08:28,460 --> 00:08:31,430
We did a little minus minus in that decommitted from five to four.

128
00:08:31,440 --> 00:08:39,170
So they really do the same thing as long as it's one plus plus increment by one minus minus decrements

129
00:08:39,170 --> 00:08:39,650
by one.

130
00:08:42,600 --> 00:08:42,850
Cool.

131
00:08:42,870 --> 00:08:48,600
So I think that's also pretty straightforward as well, except for this little part about it, which

132
00:08:48,600 --> 00:08:52,620
is something I'm going to go over right now, so I'm going to go ahead and works.

133
00:08:54,240 --> 00:08:57,450
Can't say, OK, can't seem to delete this highlight.

134
00:09:01,610 --> 00:09:06,920
OK, so I'm going to go ahead and just delete this stuff.

135
00:09:07,850 --> 00:09:09,830
I don't necessarily need that right now.

136
00:09:10,730 --> 00:09:18,410
Let's talk about this something called prefix and postfix, so you have a fusion example like this.

137
00:09:18,410 --> 00:09:25,480
So I'm going to make a new engineering and call this and and I'm going to call this like I to.

138
00:09:25,520 --> 00:09:35,480
And I say, and I two people say one, and then what I'm going to do is I'm going to say and I three

139
00:09:36,020 --> 00:09:36,800
equals

140
00:09:39,980 --> 00:09:41,270
plus plus I want.

141
00:09:43,060 --> 00:09:43,450
All right.

142
00:09:45,330 --> 00:09:53,700
And then what I'm going to do is just say and to oops, sorry.

143
00:09:53,780 --> 00:09:55,880
And know I already have it too.

144
00:09:56,820 --> 00:10:08,880
So I'm going to say I two equals or no, I for some say and I four equals I two plus plus.

145
00:10:12,070 --> 00:10:18,420
So you probably are thinking, well, these are like similar things, what you do is you set a two to

146
00:10:18,420 --> 00:10:22,660
buy one, so I one has five, then I two is going to have five, right?

147
00:10:23,410 --> 00:10:26,590
And then what you do is you make a new integer called a three.

148
00:10:28,220 --> 00:10:33,620
And then you do a plus plus I one well, I know what that does, right, it adds one to one which has

149
00:10:33,620 --> 00:10:35,590
five, so five plus one is six.

150
00:10:35,600 --> 00:10:38,180
It's going to store six in here.

151
00:10:39,880 --> 00:10:41,800
So I for here.

152
00:10:42,670 --> 00:10:43,960
Yeah, it's pretty much same thing, right?

153
00:10:43,960 --> 00:10:49,120
It's adding one to I two, which is going to be six and it's going to store that and I four.

154
00:10:49,990 --> 00:10:53,200
So let's go ahead and check out what happens here.

155
00:10:53,380 --> 00:10:55,380
So I'm going to go ahead and print out.

156
00:10:55,390 --> 00:11:00,910
I'm actually going to say kind of like our hello world, you know, in quotes, I'm going to put a little

157
00:11:00,910 --> 00:11:05,860
phrase here, but I'm just going to use it to label what we're printing out.

158
00:11:06,520 --> 00:11:16,090
So I'm going to say I won and then I'm going to actually print out.

159
00:11:16,090 --> 00:11:22,900
I want value and then I'm going to put a little column in a space and I'm going to say I three and then

160
00:11:22,900 --> 00:11:28,390
I am going to print out I 3's value and then I'm going to put the my.

161
00:11:30,340 --> 00:11:39,100
And then I'm going to do the same thing down here, but I'm going to change this to try to pronounce

162
00:11:39,100 --> 00:11:40,000
it its value.

163
00:11:40,600 --> 00:11:43,200
And then I'm going to change this to four.

164
00:11:44,340 --> 00:11:45,580
You print out my force value.

165
00:11:46,420 --> 00:11:47,560
So let's see what happens here.

166
00:11:50,080 --> 00:11:50,730
Save it.

167
00:11:50,740 --> 00:11:51,430
Compile it.

168
00:11:51,850 --> 00:11:52,240
Run it.

169
00:11:53,980 --> 00:11:54,490
OK.

170
00:11:55,510 --> 00:12:03,390
All looks pretty good, except for, whoa, what is it that we kind of might have expected this stuff?

171
00:12:04,510 --> 00:12:11,580
So we did take five and copy it into here because I one was five.

172
00:12:12,860 --> 00:12:17,740
Let's see what happened here, so we added one two.

173
00:12:18,490 --> 00:12:20,670
I won, so I won was five.

174
00:12:20,680 --> 00:12:21,550
We added one to it.

175
00:12:21,550 --> 00:12:23,640
So five is now six.

176
00:12:23,680 --> 00:12:25,810
I want us now six, right?

177
00:12:25,810 --> 00:12:26,590
So we changed.

178
00:12:26,590 --> 00:12:30,310
I won two six and that's what I printed out.

179
00:12:31,090 --> 00:12:32,170
So that kind of makes sense.

180
00:12:32,170 --> 00:12:36,160
We did the plus plus and I wanted to actually change that as well, though.

181
00:12:36,760 --> 00:12:43,780
So the variable that has the plus plus associated with it also gets changed is not just the thing that

182
00:12:43,780 --> 00:12:44,740
we save it into.

183
00:12:46,300 --> 00:12:53,500
So both of these have six now we added one to one that is six, and we took that result, which is six

184
00:12:53,500 --> 00:12:54,610
and stored it in three.

185
00:12:54,610 --> 00:12:57,430
So that's why and when we print this out, we see them both at six.

186
00:12:58,360 --> 00:13:02,190
This one, however, it added one to it too.

187
00:13:02,210 --> 00:13:04,090
So I two was five, right?

188
00:13:04,180 --> 00:13:05,890
Because we stored five and I two.

189
00:13:06,730 --> 00:13:08,680
So five now became six.

190
00:13:10,180 --> 00:13:14,980
But it didn't stop six an eye for eye forces, five.

191
00:13:15,910 --> 00:13:18,940
So what's actually happening here is something really weird.

192
00:13:19,300 --> 00:13:23,890
What it's doing is it's just evaluating this first.

193
00:13:25,550 --> 00:13:32,750
It's actually saying, Oh, I four equals I two, what is I two?

194
00:13:32,780 --> 00:13:34,010
Well, I choose five.

195
00:13:34,550 --> 00:13:36,800
OK, cool store five and a four.

196
00:13:37,580 --> 00:13:43,460
And then afterwards it's doing a two plus plus, so it's turning five into six.

197
00:13:43,970 --> 00:13:46,430
But it just already stored five and I four.

198
00:13:46,430 --> 00:13:49,910
So it's not restoring six, it's just storing five and I have four.

199
00:13:50,330 --> 00:13:51,770
So that's why it prints out.

200
00:13:52,040 --> 00:13:53,440
I four is, which is five.

201
00:13:53,450 --> 00:13:54,260
It only has five.

202
00:13:54,680 --> 00:14:01,050
But I two got incremented to six after the storage part happened.

203
00:14:01,070 --> 00:14:05,660
The assignment after the assignment happened, so five got stored in the.

204
00:14:06,980 --> 00:14:13,160
Then afterwards, it's just leaves my four alone and it then increments I to.

205
00:14:15,430 --> 00:14:17,770
So pretty interesting concept here.

206
00:14:18,550 --> 00:14:22,540
This is called prefix versus postfix, so this would be prefix.

207
00:14:22,930 --> 00:14:24,250
This would be postfix.

208
00:14:24,550 --> 00:14:28,420
You can think of pre and post like before and after.

209
00:14:28,900 --> 00:14:37,480
So this style makes the incremental version happen before this style makes the incremental version happen

210
00:14:37,480 --> 00:14:38,830
after so.

211
00:14:39,960 --> 00:14:44,820
Pretty, pretty weird, pretty weird, but just something to keep in mind, also something to keep in

212
00:14:44,820 --> 00:14:51,090
mind is the fact that this plus plus changes the value of this variable as well.

213
00:14:51,090 --> 00:15:01,410
It's not just only storing a result in here, like let's go ahead and change this to high one plus equals

214
00:15:01,410 --> 00:15:01,740
one.

215
00:15:04,460 --> 00:15:05,780
And see what happens here.

216
00:15:06,920 --> 00:15:08,690
I won't put this even in parentheses here.

217
00:15:11,360 --> 00:15:12,950
Let's see what C++ does.

218
00:15:13,670 --> 00:15:14,670
See if he yells at us.

219
00:15:14,780 --> 00:15:15,500
No, it doesn't.

220
00:15:17,540 --> 00:15:17,990
OK.

221
00:15:18,230 --> 00:15:24,500
So you notice that it actually does the same thing here.

222
00:15:24,890 --> 00:15:30,800
If we do this, so if we do the plus equals one, it's actually doing that.

223
00:15:31,220 --> 00:15:34,790
But if I was to just do this, let's go ahead and say this.

224
00:15:38,110 --> 00:15:39,580
So I say this, compile it.

225
00:15:41,230 --> 00:15:46,660
Now you notice that I want to still five, so this had an equals on it, so it actually assigned it.

226
00:15:47,620 --> 00:15:54,940
But before we were just using a like a plus plus I right now, we do one plus one.

227
00:15:55,300 --> 00:15:57,790
It's not actually changing.

228
00:15:57,790 --> 00:16:05,530
I one to A1 plus one, it's just taking the result and storing it inside this i3, unlike the plus plus

229
00:16:05,530 --> 00:16:12,280
i1, where in this case, it actually modifies both.

230
00:16:13,720 --> 00:16:20,140
So it modifies the i1 by increment it by one, and then it takes that result in stores in here.

231
00:16:20,590 --> 00:16:22,570
So both variables get changed.

232
00:16:23,620 --> 00:16:25,480
Similar thing with minus minus.

233
00:16:28,710 --> 00:16:30,630
I can change this to minus minus.

234
00:16:31,200 --> 00:16:34,170
And we're going to see a similar style of result.

235
00:16:36,120 --> 00:16:42,540
So you notice that these two are the same when we do the pre and communication.

236
00:16:43,650 --> 00:16:49,110
But when we do the posting fermentation, we notice that it does the same thing where it stores it to

237
00:16:49,110 --> 00:16:53,850
its original value and 04, and then it just changes it to with the minus minus.

238
00:16:54,270 --> 00:16:57,540
So that's why you see A4 here has five.

239
00:16:58,260 --> 00:17:02,310
Yet the two got decommitted from five to four.

240
00:17:04,900 --> 00:17:12,910
OK, so this is probably kind of a lot again, you know, each one of these kind of beginning of the

241
00:17:12,910 --> 00:17:16,120
course lectures is stuffing a lot of information into your brains.

242
00:17:16,810 --> 00:17:20,530
What you should really do is practice all of this as much as you can.

243
00:17:20,530 --> 00:17:22,480
So use all of it together.

244
00:17:23,020 --> 00:17:27,670
Go ahead and use all the standard operators.

245
00:17:27,670 --> 00:17:30,940
Combine them with the parentheses.

246
00:17:30,940 --> 00:17:33,490
Make the biggest mathematical expressions.

247
00:17:33,490 --> 00:17:37,510
You can save those and other variables.

248
00:17:37,540 --> 00:17:40,900
Update them with the plus equal minus equal times equal.

249
00:17:41,170 --> 00:17:49,210
Print them out and then also mess around with the prefix and postfix here with the incremental option.

250
00:17:51,510 --> 00:17:54,550
OK, so hopefully that was enough to explain these concepts for you.

251
00:17:54,570 --> 00:17:56,890
Like I said, get as much practice as you can.

252
00:17:56,910 --> 00:18:05,400
We don't have actual assignments yet because we kind of need to learn some more tools, learn about

253
00:18:05,400 --> 00:18:09,180
some more tools to be able to solve some actual problems.

254
00:18:09,210 --> 00:18:11,900
So right now, it's all about practice makes perfect.

255
00:18:11,910 --> 00:18:12,210
All right.

256
00:18:12,570 --> 00:18:19,260
So practice everything that you've learned so far, which is making variables messing around with them

257
00:18:19,260 --> 00:18:26,130
with operators, both logical, right, which we learn before and arithmetic now that, you know, medic

258
00:18:26,640 --> 00:18:27,900
print stuff out.

259
00:18:27,930 --> 00:18:36,690
So it's always like variables, mess, mess around with variables so, you know, changing them and

260
00:18:36,930 --> 00:18:42,420
changing them, making new variables, modifying them, printing those variables out, printing those

261
00:18:42,420 --> 00:18:44,700
variables out in expressions like this.

262
00:18:45,920 --> 00:18:54,680
And, you know, just kind of repetition and getting that stuff down, because very soon, in fact,

263
00:18:54,680 --> 00:19:01,430
in the next few lectures, we're going to move on past just having these basic primitive types and variables,

264
00:19:01,430 --> 00:19:03,890
and we're going to look at some much bigger concepts.

265
00:19:04,580 --> 00:19:04,870
All right.

266
00:19:04,880 --> 00:19:07,130
So with that, I will see you in the next lecture.
