Tim: All right, so moving on with our discussion
on operators, there is a way to abbreviate
when we're actually using many operators.
So let's have a look at one,
now we've used the example before
and I'm just gonna introduce a comment here.
We've done this before, we've done result = result + 1,
so we saw what happened when we did that statement.
We can abbreviate that statement by typing result++.
Two + operators, and a semi-colon to end the line.
Let's add a comment there,
we know that the value from the last operation
gave us the result of one.
This is going to be 1 + 1.
No surprises that's gonna give us the value two.
Lets just confirm it so I will put 1 + 1 = + result.
That's an abbreviation for doing the result = result + 1,
using result++.
One plus one equals two, all right?
So far so good, and we can do the same
for the other major operators as well.
So let's do the same for the subtraction.
So we do result-- and that's going to give us.
You know the last operation was two, so 2 - 1 = 1.
Let's print that out 2 - 1 = + result.
Now that's just a shorthand way of writing
result equals result take one.
Two minus one equals one.
Now we can actually even reduce assigning a value
by a different value.
If you wanna add two for example to result,
you'd normally have to do something like this.
Result = result + 2, we can abbreviate that by typing
result += 2; what that should give us,
we know that the result's currently one so that's gonna be
1 + 2 = 3, let's print it out, 1 + 2 = + result
should give us three.
Let's run that, so again that's just an abbreviation
to result = result + 2 is 1 + 2 = 3.
And we can do the same for multiplication.
Let's do a couple of 'em just to show you
that that will still work.
So we can type equivalent to result = result * 10,
we can do result *= 10, now that should give us,
we know the last answer was three.
That should give us 3 * 10 = 30.
Let's print that out, 3 * 10 = that should be 30.
And there it is 3 * 10 = 30.
All right and I'll do one more, we'll do the division,
and obviously subtraction will work the same way as plus.
Result = result / 3 can be abbreviated to result /=,
so /= 3.
And that should give us, we know we've got 30
on the left hand side, / 3 should give us 10.
So print that out 30 / 3 = the answer should be 10.
All right, let's do one last,
we'll actually finish off and do the other one
just to be consistent if we end the video.
Result = result - 2 for arguments sake, let's do that.
Result -= 2, we know the value for that is,
the last value of result was 10 so 10 - 2
should give us the answer 8.
So we'll print that out, 10 - 2 = + result,
it should give us the value of 8.
10 - 2 = 8, And you can see that is done there.
All right so let's finish the video here.
In the next one, we're gonna continue exploring
yet more operators, but to do that we need to first talk
about the if then statement.
So we'll work on that in the next video.