Welcome back.
In this video, we are going to check out the assignment operators and the increment or decrement operators
because we are going to use them quite a bit.
So assignment operators are the ones you can see here.
And we have already seen them to a certain degree where we just had a variable and I'm going to call
this one, my name is going to be five and then I can go ahead and say my name, plus equal three.
So what I will do is it will add three to my num value.
So it's going to be the same thing as if I wrote my number equals my NUM plus three.
All right.
So these two are interchangeable and as you can see, it even prefers the other one.
So it even prefers the operator assignment, as we have seen here.
All right.
So assignment operator, is this plus equal three or this minus equal or multiplied equal and so forth.
So now I can of course, go ahead and print this print and it's going to be my name is Tolda my name
and I'm going to comment on all our other print line statements from earlier videos.
And it's around this again.
And as we see says, my name is eight.
All right, so that is an assignment operator.
Now, please go ahead and multiply that with four.
So multiply my number with four and stored that in my number to use an assignment operator for this.
All right, I hope you tried it, so it's my num multiplication or asterisk equal four, and now let's
print this again.
And the next line.
And we can see it's 32, all right, so these are the assignment operators.
Now let's look at the increment and decrement operators because they are something that is used quite
often as well.
And they're just a double plus or double minus sign.
So we can just go ahead and do the following myname plus plus nothing more than that.
So let's print my name again.
And this is going to be here, actually gets printed here, and that's printed after the incrementing,
so this plus plus is incrementing, which means increasing the value by one and then minus Moniz's decremental,
which means decreasing the value by one or reducing one.
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
and 33 in this line.
So that's what this increment does.
Now let's do a decrement.
And at that same time, I want to show you something that is super interesting, and that is to use
the increment after use, which means we use increment after my name and then again, we can use it
before.
So in this case, you can see we cannot just use this approach, we have to use the brackets.
So I'm going to use curly brackets here as well, because this is an expression that I want to execute
before actually printing it on the screen.
So let me show you how this will impact our application here.
So let's run this again.
All right, so there we are.
So we had my numbers, 33, that's this line here, right?
So we increased my number of being 32, which was at this point, and then we increased it by one here.
Then we go ahead and print that number and then we say, OK, let's increase the value by one.
But for some reason, it didn't increase the value.
Why is that?
Well, that is because this plus plus will only be executed once this line of code is finished.
So pretty much at the beginning of the next line.
So in line 75, my number is still 33.
Then it's increased by one.
So in line seventy six at the beginning of the line it's going to be 34 and then would you plus plus
minus.
Which means we increment just before we execute or we use this variable, which means that now it was
34 at this point plus one, which means now it's 35 and that's exactly what is printed onto the console.
So now you can see that my name is 35.
So that's the difference between using the plus plus or the increment or decrement operators before
or after, because it really has an impact on when they are executed.
And now, you know, the difference.
But very commonly it's used afterwards.
So you increment after words because usually you don't use it in line as we do it here.
So now please add another print line statement just underneath it, so in line 77, in my case, just
underneath this statement, and they're decreased to value so that it will show my name is 34 as the
next print line statement.
All right, so I hope you tried it.
So what I need here, of course, is to use minus minus before my name and not after my name.
So I'm going to decrement the mine unbearable just before it is going to be displayed and printed onto
the console.
So just before it will be used to say so.
There we are.
It says, my name is 34.
All right, so that's assignment operators and the increment and decrement operators, and in the next
video, we are going to see how we can finally use some of those operations usefully, because so far
we had some examples of what we can do with it.
But now let's see what we actually can do with it and get something from it, because so far it has
been rather fundamental or rather basic.
So see in the next video where we're going to check out if statements.