3.3 The Assignment Operators

Hello everyone and welcome to this video so we're going to look at the 2nd category of operator that we're going to look at which is the assignment operators. We've already seen an example of an assignment operator so here we're using the simple assignment operator to assign a value, so in this case x = 10. But we have some other assignment operators. So in the last video we saw the increment operator with that we increment the value of x by 1, this expression here is exactly equivalent to that, so x = x + 1. We read the value of x by adding 1 to it, then using the assignment operator, assign this new value to x. But what if in this example instead of adding 1 to x, we want to add 5. Well that increment operator won't work. So how can we do that, so to do that there is a simple way, so a shortcut, we can use addition. The assignment operator like that. So line 5 and line 4 are exactly the same. Here is another example. Let's say we want to multiply the value of x by 3. We can write it like this x = x * 3 or use the multiplication operator like this. So all the other arithmetic operators that you knew in the last video, so addition subtraction division multiplication and other operators, all of these have a combination with the assignment operator. That's it for this video on assignment operators so we'll see you in the next video where we'll talk about comparison operators.