1
00:00:00,480 --> 00:00:01,280
Welcome back.

2
00:00:01,540 --> 00:00:09,060
In this video, we are going to check out the assignment operators and the increment or decrement operators

3
00:00:09,060 --> 00:00:10,720
because we are going to use them quite a bit.

4
00:00:10,980 --> 00:00:13,680
So assignment operators are the ones you can see here.

5
00:00:13,680 --> 00:00:19,650
And we have already seen them to a certain degree where we just had a variable and I'm going to call

6
00:00:19,650 --> 00:00:27,510
this one, my name is going to be five and then I can go ahead and say my name, plus equal three.

7
00:00:27,720 --> 00:00:32,540
So what I will do is it will add three to my num value.

8
00:00:32,549 --> 00:00:40,430
So it's going to be the same thing as if I wrote my number equals my NUM plus three.

9
00:00:41,070 --> 00:00:41,440
All right.

10
00:00:41,460 --> 00:00:47,630
So these two are interchangeable and as you can see, it even prefers the other one.

11
00:00:47,640 --> 00:00:52,800
So it even prefers the operator assignment, as we have seen here.

12
00:00:53,340 --> 00:00:53,790
All right.

13
00:00:53,820 --> 00:01:01,670
So assignment operator, is this plus equal three or this minus equal or multiplied equal and so forth.

14
00:01:02,040 --> 00:01:10,590
So now I can of course, go ahead and print this print and it's going to be my name is Tolda my name

15
00:01:11,460 --> 00:01:19,290
and I'm going to comment on all our other print line statements from earlier videos.

16
00:01:19,290 --> 00:01:20,220
And it's around this again.

17
00:01:22,280 --> 00:01:25,320
And as we see says, my name is eight.

18
00:01:25,970 --> 00:01:29,000
All right, so that is an assignment operator.

19
00:01:29,010 --> 00:01:32,330
Now, please go ahead and multiply that with four.

20
00:01:32,330 --> 00:01:38,300
So multiply my number with four and stored that in my number to use an assignment operator for this.

21
00:01:40,810 --> 00:01:50,680
All right, I hope you tried it, so it's my num multiplication or asterisk equal four, and now let's

22
00:01:50,680 --> 00:01:51,510
print this again.

23
00:01:53,560 --> 00:01:54,460
And the next line.

24
00:01:55,910 --> 00:02:00,960
And we can see it's 32, all right, so these are the assignment operators.

25
00:02:01,200 --> 00:02:07,700
Now let's look at the increment and decrement operators because they are something that is used quite

26
00:02:07,700 --> 00:02:08,680
often as well.

27
00:02:08,810 --> 00:02:12,580
And they're just a double plus or double minus sign.

28
00:02:12,950 --> 00:02:20,090
So we can just go ahead and do the following myname plus plus nothing more than that.

29
00:02:20,570 --> 00:02:23,030
So let's print my name again.

30
00:02:25,140 --> 00:02:32,180
And this is going to be here, actually gets printed here, and that's printed after the incrementing,

31
00:02:32,430 --> 00:02:39,480
so this plus plus is incrementing, which means increasing the value by one and then minus Moniz's decremental,

32
00:02:39,570 --> 00:02:43,500
which means decreasing the value by one or reducing one.

33
00:02:45,330 --> 00:02:51,840
So once we run this, we can see my name is 32 and my name is 33, so my name is 32 here at this line

34
00:02:52,110 --> 00:02:54,250
and 33 in this line.

35
00:02:54,810 --> 00:02:56,460
So that's what this increment does.

36
00:02:56,460 --> 00:02:58,860
Now let's do a decrement.

37
00:02:58,860 --> 00:03:06,960
And at that same time, I want to show you something that is super interesting, and that is to use

38
00:03:06,960 --> 00:03:15,480
the increment after use, which means we use increment after my name and then again, we can use it

39
00:03:15,480 --> 00:03:16,260
before.

40
00:03:17,650 --> 00:03:23,140
So in this case, you can see we cannot just use this approach, we have to use the brackets.

41
00:03:23,140 --> 00:03:30,070
So I'm going to use curly brackets here as well, because this is an expression that I want to execute

42
00:03:30,340 --> 00:03:33,220
before actually printing it on the screen.

43
00:03:33,370 --> 00:03:38,650
So let me show you how this will impact our application here.

44
00:03:40,420 --> 00:03:42,180
So let's run this again.

45
00:03:44,310 --> 00:03:45,420
All right, so there we are.

46
00:03:45,780 --> 00:03:49,220
So we had my numbers, 33, that's this line here, right?

47
00:03:49,350 --> 00:03:58,030
So we increased my number of being 32, which was at this point, and then we increased it by one here.

48
00:03:58,470 --> 00:04:05,760
Then we go ahead and print that number and then we say, OK, let's increase the value by one.

49
00:04:06,540 --> 00:04:08,830
But for some reason, it didn't increase the value.

50
00:04:08,850 --> 00:04:09,540
Why is that?

51
00:04:09,960 --> 00:04:18,589
Well, that is because this plus plus will only be executed once this line of code is finished.

52
00:04:18,600 --> 00:04:21,000
So pretty much at the beginning of the next line.

53
00:04:21,000 --> 00:04:25,780
So in line 75, my number is still 33.

54
00:04:26,370 --> 00:04:27,990
Then it's increased by one.

55
00:04:27,990 --> 00:04:36,180
So in line seventy six at the beginning of the line it's going to be 34 and then would you plus plus

56
00:04:36,180 --> 00:04:36,570
minus.

57
00:04:36,660 --> 00:04:44,220
Which means we increment just before we execute or we use this variable, which means that now it was

58
00:04:44,220 --> 00:04:51,480
34 at this point plus one, which means now it's 35 and that's exactly what is printed onto the console.

59
00:04:51,510 --> 00:04:55,460
So now you can see that my name is 35.

60
00:04:55,830 --> 00:05:01,500
So that's the difference between using the plus plus or the increment or decrement operators before

61
00:05:01,530 --> 00:05:06,680
or after, because it really has an impact on when they are executed.

62
00:05:06,690 --> 00:05:09,210
And now, you know, the difference.

63
00:05:09,570 --> 00:05:12,120
But very commonly it's used afterwards.

64
00:05:12,120 --> 00:05:17,910
So you increment after words because usually you don't use it in line as we do it here.

65
00:05:19,870 --> 00:05:25,720
So now please add another print line statement just underneath it, so in line 77, in my case, just

66
00:05:25,720 --> 00:05:35,980
underneath this statement, and they're decreased to value so that it will show my name is 34 as the

67
00:05:35,980 --> 00:05:37,560
next print line statement.

68
00:05:39,510 --> 00:05:41,160
All right, so I hope you tried it.

69
00:05:42,060 --> 00:05:47,830
So what I need here, of course, is to use minus minus before my name and not after my name.

70
00:05:47,880 --> 00:05:56,880
So I'm going to decrement the mine unbearable just before it is going to be displayed and printed onto

71
00:05:56,880 --> 00:05:57,490
the console.

72
00:05:58,170 --> 00:06:01,620
So just before it will be used to say so.

73
00:06:01,620 --> 00:06:02,230
There we are.

74
00:06:02,280 --> 00:06:04,590
It says, my name is 34.

75
00:06:05,480 --> 00:06:12,650
All right, so that's assignment operators and the increment and decrement operators, and in the next

76
00:06:12,650 --> 00:06:19,790
video, we are going to see how we can finally use some of those operations usefully, because so far

77
00:06:20,060 --> 00:06:23,230
we had some examples of what we can do with it.

78
00:06:23,240 --> 00:06:28,940
But now let's see what we actually can do with it and get something from it, because so far it has

79
00:06:28,940 --> 00:06:31,820
been rather fundamental or rather basic.

80
00:06:31,830 --> 00:06:35,540
So see in the next video where we're going to check out if statements.

