‫Welcome back.
‫In this video, we are going to cover operators and there is plenty to know about these little things
‫which have a lot of impact onto our programs.
‫So let's get started straightaway by creating two variables which have a value and one that does not
‫have a value for now.
‫So I'm just going to keep it simple, number one, two and three.
‫And the first one is a value of five.
‫The second one is three, and the third one is empty for now.
‫And now let's go ahead and use a urinary operator or multiple ones.
‫So the first one that I'm going to show you is I'm going to store the value of minus number one in number
‫three.
‫So what that's going to do is it will multiply number one with minus one.
‫If we run that.
‫So C W console, red line, double tab.
‫And in here I'm going to write something like num three is and here I use curly brackets zero.
‫Well that will do is it will simply replace this whole thing here with the first variable that comes
‫after this comma.
‫So it's going to be number three in my case.
‫So now I need console dot read key so that my program doesn't stop.
‫Once I started and we are number three is minus five.
‫All right, so there you are.
‫You see it just multiplies it with minus one.
‫And in order to check if that's true, we do the same thing.
‫But now we use NUM one as minus five and they were now it says it's positive so it just multiplies it
‫with minus one.
‫Great.
‫So that's the first one.
‫Now there is another one and you can do that with logical ones as well.
‫So let's have a pool which is sunny and let's create it as true and now console right line.
‫So see W double tab.
‫Is it sunny?
‫It's always a good question and it's nice if it is so it's sunny.
‫That's how you would usually call this sunny variable, right?
‫So now I'm going to use an exclamation mark just in front of it, just before it.
‫So what that will do is it will negate it.
‫So it will be just the opposite.
‫So if it was true before, now it's going to be false.
‫So let's check if that's true.
‫Is it Sunny and it says false?
‫All right.
‫So just negation with a simple exclamation mark.
‫Now, the next thing that I want to show you are increment operators.
‫So let's go ahead and use increment operators.
‫And the first one is going to be a new variable, by the way, is going to be zero.
‫And now what I want to do is I want to increment it and I do that by using the num plus plus.
‫So I'm just going to copy the code from here and I'm going to use NUM as the variable.
‫So now let's write that onto the console and see let's see what happens.
‫And we see NUM is one, so we initialize it with zero and afterwards we increased it by one.
‫So we incremented it by one and well, that's what changed here.
‫So now the next thing that I would like to show you is something that's pretty interesting.
‫So I'm just going to copy that twice and I'm going to increment inside of this statement here, inside
‫of the right line call.
‫And what we get here is NUM is one.
‫So as it was in line 27, then in line 28, NUM is still one and the line 29 it is suddenly two.
‫So we increment it, but it only takes effect in the next line.
‫That's something that is really important.
‫So if we want it to be changed in the same line as we use it, then we use the double plus at the beginning.
‫So just before the variable name.
‫So if we run that again we will see num is one then it's still one because incrementing happens only
‫afterwards and then num is three.
‫So the incrementing here happens just before.
‫So we have the increment of the row 28 or line 28 and then we have another increment in line 29.
‫And that's why we get a value of three here instead of two.
‫All right.
‫So that's how you can use increment operators.
‫You can use the pre increment, that's how it's called pre increment.
‫And then that will be the post increment here.
‫That one is the post increment line 28.
‫All right.
‫So now the same happens or same applies to decrement operator.
‫So it's just num minus minus.
‫So it's the same thing, only that it's with the minus.
‫Now instead of a plus, I'm just going to copy the code from the top there.
‫And instead of using plus plus here, I'm using minus, minus.
‫And the same applies to this line here.
‫So if you run that again.
‫We can see it was three then it was decrement it here.
‫And actually, this is a predicament.
‫Let me just change that because I copied it and it's good to have it right straight away.
‫So once again, we start at one, then we increase.
‫We increase again and then we decrease in here.
‫Line 33, we show it onto the console, then we decrement once again in line 35 and once again in line
‫37.
‫But there we predicament.
‫So now we have both decrements stated just here.
‫So that's the increment and decrement.
‫Now let's have a look at the additive and multiplicative operators.
‫They're pretty straightforward, but they're still important.
‫So let's have a look at them.
‫You probably know them already and we used some of them, but just to complete everything, I want to
‫use it here.
‫So I'm just going to use result and result is going to be number one plus number two.
‫And you might recall number one was five and number two was three.
‫So that should be eight.
‫And there's nothing wrong about that.
‫So let's just.
‫Use this console right line.
‫Again, just to keep it simple, I'm going to say result of num one plus num two maybe that's better
‫is and it's going to be the result here.
‫So if we add that's plain simple it should be eight that we are a result of number one plus number two
‫is eight.
‫So five plus three is eight.
‫Now we do the same thing with minus.
‫And now let's use a minus sign here.
‫If you run it, then we see it's two.
‫So five minus three is two.
‫So nothing fancy here.
‫And now let's have a look at multiplying and dividing.
‫So I'm going to do that.
‫And the same thing result of and that was actually minus and that one will be divided and the last one
‫will be multiplication.
‫So let's run that again and still nothing fancy.
‫So if you want to divide, you simply use the slash.
‫If you want to multiply, you use the star, right?
‫So five times three is 15, then five divided by three is one and it's simply one because we have integers
‫here and integers don't understand what floats are, so they can't have anything behind the decimal
‫point or after the decimal point.
‫So if you would use doubles instead, then we would get a more precise value.
‫But otherwise it's just one and it doesn't round down or round up.
‫It just cuts off anything that is behind the decimal point.
‫So that's how integers divide.
‫Then there is one more thing and it's called the modulo operator and the modulo operator is done like
‫that.
‫And what that will do is it will result in two.
‫So we divide value one by two and we simply return the remainder.
‫So.
‫Just gives us the remainder and in our case, num one divided by num two.
‫So five divided by three is one remainder two.
‫That's what we get here.
‫So that's what you need to modulo four and that's pretty useful.
‫So don't underestimate the modulo you might not have used it so far in school or whatever, but it's
‫pretty useful in programming.
‫So keep it, keep that in mind.
‫Then the next one is relational and type operators.
‫So I'm going to create a bool here and I'm going to call it is lower and I'm going to set is lower two
‫num one lower num two.
‫And what that will return if.
‫No one is actually lower or lower value than number two.
‫So we check is five lower than three.
‫And if we simply print that onto the console, let's do that result of number one lower.
‫Number two is and it's going to be is lower.
‫So let's run that again.
‫And we see result of number one, lower.
‫Number two is false.
‫And that is because well, five is not lower than than three.
‫And that's pretty much what we say here.
‫So if we turn it the other way around.
‫So we said number one is higher than them, two are bigger than them.
‫Two, we get the statement here, result of is true.
‫So that's what you can simply do.
‫So you can compare and you can store something within a variable straight away after checking something
‫here.
‫So this is a relational operator here and we can do the same thing with double equal sign.
‫So it's going to equality operator and I'm going to create a blue here is equal and I'm going to say
‫is equal is going to be the result of num one is equal to num two.
‫So you have the double equal sign and you use that for comparisons.
‫So you compare is whatever is on the right, the same as whatever is on the left.
‫So this one is an assigning equal sign and that one is a comparing equal sign or a double equal sign
‫is comparing.
‫So in operator end left and right.
‫So as you can see, this is actually a method that is called here bool int dot operator is equal to.
‫So that's pretty cool.
‫It does that for us automatically and it stores the result and is equal.
‫So as you can see, if I double tap on that, it says it returns a bull bull int dot operator.
‫So it's method there is a method behind that and it's called in order to give us the result.
‫And I'm just going to use that and I'm going to say is double equal is equal here.
‫So let's run that again and we see result of num one is equal, num two is false and that is because
‫three is not equal to five.
‫And that's pretty much it, right?
‫So now that's equality.
‫And now we have the opposite of equality.
‫And I'm going to simply say is equal is going to be number one, not equal.
‫Number two, that will return true.
‫On the other hand, because the statement here is actually true because number one is not equal.
‫Number two.
‫And if we double tap here.
‫Hint operator.
‫Not equal in left and right.
‫So it's comparing those two and it says, are they equal or not equal?
‫And it's actually going to be not equal.
‫So it means it's true.
‫So you see the last statement result of num one, not equal num two is true.
‫So this video is getting pretty long and I'm going to end it with the conditional operators.
‫So conditional operators and those ones will be pretty handy as soon as we go into if and else if the
‫same with equality operators and those relational ones.
‫So we're going to use all of those when we use if statements and that's really, really important.
‫So let's go ahead and create another boolean and I'm going to call it is lower and sunny and I'm going
‫to check is lower and sunny is going to be is lower and is sunny.
‫How crazy is that?
‫So we use those two booleans is lower.
‫That's that one here and the one is sunny.
‫That's the one right at the start here in line 21 in my case bool is sunny was set to true and here.
‫I'm actually.
‫I still have it as true, even though I'm negating it here.
‫But I'm only negating it for this sentence here.
‫I'm not negating the variable itself, so it should still be true.
‫So is sunny is still true.
‫Now checking is lower.
‫Also true.
‫So let's have a look.
‫Pool is lower num one bigger than that.
‫So it's not going to be true because number one is not higher than num two.
‫So this whole statement here is going to be false.
‫So let's check that.
‫Let's write it on to the console.
‫And we just going to say result of is lower and is sunny is and then it's going to be is lower and is
‫sunny now if you run that result of is lower and is sunny is true.
‫All right.
‫So now let's check why that is, because we checked here.
‫Number one is higher than number two.
‫And that is actually true because number one was five and M two is.
‫Three.
‫So that's why we have to turn it around here.
‫And now that statement is true.
‫So the whole statement is only true if both statements are true, and that's why it's lower and sunny
‫is true.
‫So it's pretty much like the end.
‫You might have seen that at school.
‫So end condition one and condition two, or in our case, bool one and bool two has to be true.
‫Otherwise this whole is lower and sunny is not true.
‫So if we turn it around now and we check it again, then this whole statement will be false.
‫So result of is lower and is sunny is false.
‫All right.
‫So one more thing.
‫And that's the last one for this video.
‫And that's where we compare the or or we use the OR operator, which is is lower and sunny is going
‫to be is lower or is sunny.
‫So we have seen that this one was false already because one of the two was not true or both were not
‫true.
‫But we know that it's sunny was true, actually.
‫So now this whole statement is going to be true as well.
‫So let me copy that and use the double pipe.
‫So you need to use the double pipe here.
‫Then we see result of is lower or is sunny is true and that is because is sunny is true.
‫And if is is lower is also true, then this statement is still true.
‫Only if both of them are false, then is lower and sunny is going to be false.
‫So that's the or so here.
‫Condition one or condition two has to be true.
‫Then this whole statement is true.
‫Otherwise, it's false.
‫All right.
‫So plenty of operators and.
‫Yeah.
‫So now you have seen all of them and there is no exercise for this video.
‫I'm sorry, but there will be plenty of exercises in the following videos.
‫So if you are not 100% sure about one of them, just check the video at that point once again and try
‫to copy all of the code and try to understand every single step because those are very, very important
‫basics that we are just going to use a lot and we're going to use them without really going too much
‫into detail about what they do, because we did that here.
‫So from now on, I'm going to use those things as if they are in your flight, flesh and blood, and
‫you know them by heart.
‫And I could wake you up at 3:00 and say, number one, equal, equal number two, is it true or not?
‫And you get the two values.
‫Then you have to say, okay, yeah, that's true.
‫And then based on that, you either get water on your face or you don't.
‫So that's pretty much the approach here.
‫So hope you enjoyed the video.
‫It was a long one, I know that.
‫But in the next video, we're going to go ahead and do something shorter.
‫So see you there.