Welcome back.
We looked at incrementing in the last video.
Now let's look at Decrementing.
It's basically the same concept, only that you now use the minus.
So you could say num minus minus which basically just reduces the number by one.
So this can be useful if you want to count down for example.
So here I'm going to display num like so again so num is and then whatever num is at that point.
So we're decrementing decrementing.
All right.
Let's run it again.
And we see num now is two.
So it went all the way up to three.
And then afterwards we decremented it.
And here the same rules apply.
So you can do the same thing as we've done here where we do pre decrementing and so forth.
So let me just copy all of that and then display it to you.
So instead of plus plus we're using minus minus here.
And same goes here just for your demonstration okay.
So we see this was the highest point which was at line 12.
That's where we are at line 15 slash 16.
So it's 16.
We're displaying this line at 17.
We're displaying this line.
So we're decrementing before using the number.
Then we're using the number which is why the number is at one at this point.
And then we use num is one.
And we're decrementing after the fact which we then display in line 19.
Okay.
So this is called decrementing.
And then there is another thing that we haven't covered yet.
And I want to show you as well.
And that is for example, if you have a number and you don't want to increment it by one, but you want
to increment it by a very specific value, let's say by 30, then you can just use plus equal 30.
Or if you want to reduce it by let's say ten or whatever, then you can use minus equal.
Okay.
So let me show you what this looks like in both variants.
Let me actually comment all of that out.
So I'm marking everything.
And then I'm clicking on this little button here.
So control k.
Control C would be the combination.
You have to do it fast so that it works.
Or you can just press this button and then it comments all of those lines out.
All right.
So now let me run and actually make sure okay so num was zero zero.
And then we incremented it by one.
And then we incremented it by 30.
So it should be 31 at this point.
And at this point it should be 21.
So let's run it.
And we see num is zero.
Then num is 31 and then numbers is 21.
So that's a very easy way to manipulate a variable.
Now the cool thing is that doesn't only work with plus and minus.
This also works with multiplying as well as dividing.
So if I go ahead and say num multiply equal ten, then this will multiply the number to 210in this case.
So 21 times ten is 210.
And the same goes for division.
So let's do a division divide equal 20.
So we should get ten using this because 210 divided by 20 is 10.05 which then ends up being ten because
we're only working with integers okay.
So we only have ints here, which is why you see we get this value here.
So there we are.
Basically this is a little bit more about the different types of operators that I wanted to make sure
that you have seen, and you don't feel lost whenever I use them.
There's one last one.
I think the video is not too long.
If I also show you that operator, and that is the modulo operator.
So let me get rid of all of that, or actually let me comment all of that out.
Let me do it this way.
Like so and then like so okay.
So basically I'm commenting everything out and this num plus plus I'm going to give it away as well.
So I have num one which will be let's say ten.
And then I have int num two which is going to be three.
And now I'm using the result which will be num one modulo num two.
So what is modulo going to do.
Modulo is going to divide and give me the remainder.
So ten divided by three is three remainder one.
So the result will be one now.
So let me print that out CW well it doesn't want to help me here.
So I'm going to use console dot write line result okay.
Now let's run this again.
And we will see that we do get a one in fact okay.
So this is because let me write it down ten divided by three equals 3.333 or.
Equals three remainder one.
Okay.
So that's what's happening here with this modulo operator.
And the name is modulo operator.
All right.
So in case you ever need that you need to understand that the percentage sign is your modulo operator
that you can use in order to get the remainder of a calculation.
This can be very handy in many situations.
Now you just have seen how to work with it.
Okay, so that's it for this video.
See you in the next one.