1 00:00:00 --> 00:00:02 Welcome to this tutorial on basic arithmetic operators. 2 00:00:03 --> 00:00:08 I'll first go through plus, minus, multiply and divide operations. 3 00:00:09 --> 00:00:16 These are written as p lus, minus, multiply as an asterisk and divide as a forward slash. 4 00:00:17 --> 00:00:19 So, I will have 2 variables. 5 00:00:20 --> 00:00:29 I'll create a variable called "num1" and I'll save that as value equal to "10" and "num2" is equal to "2". 6 00:00:30 --> 00:00:33 So, these are both integer numbers with no decimal point. 7 00:00:34 --> 00:00:39 Okay, now, say I want to add "num1" and "num2" together. 8 00:00:40 --> 00:00:43 So I echo out the answer of "num1" added to "num2". 9 00:00:44 --> 00:00:46 Let's test it out. 10 00:00:47 --> 00:00:54 So, that's "12". 10 and 2, num1 and num2, when 10 and 2 are added, the answer is "12". 11 00:00:55 --> 00:01:00 Okay now let's try minus. We will just replace the minus symbol there. 12 00:01:01 --> 00:01:04 Refresh and that will be "8". 13 00:01:05 --> 00:01:10 Now lets try multiplication. 10 times 2 is 20 and we've got "20". 14 00:01:11 --> 00:01:17 Next, 10 divided by 2 is just half of 10 which is "5". 15 00:01:18 --> 00:01:23 Now, what we can do is we can add something on the end of this. 16 00:01:24 --> 00:01:26 So, let's say this is divided by num2. 17 00:01:27 --> 00:01:38 So, what I think this operation will do is, it will add "num1" and "num2", so that is 10 and 2 which will give us 12 and then 12 divided by 2. 18 00:01:39 --> 00:01:42 So, 12 divided by 2 should give 6. 19 00:01:43 --> 00:01:55 But actually what this does is it takes num2 and divides it by num2 which will give 1 and add num1 to that. 20 00:01:56 --> 00:01:59 So, that means, instead of 6 we will get 11. 21 00:02:00 --> 00:02:09 Now, the reason for this is that division operator will always work before addition operator. The same with multiply 22 00:02:10 --> 00:02:15 Now, to solve this, we should put brackets. 23 00:02:16 --> 00:02:28 The brackets will say - we'll take this operation first, do whatever is in here and then continue to divide by whatever this could be an integer or a variable. 24 00:02:29 --> 00:02:38 So, here what it will do is num1 plus num2 which is 10 plus 2 which gives us 12 divided by 2 which should give us 6. 25 00:02:39 --> 00:02:42 Let's refresh that and we can see that it worked! 26 00:02:43 --> 00:02:47 So, these are the basic arithmetic operators which are simple to use. 27 00:02:48 --> 00:02:54 If you come across any problems, always verify your calculations with a calculator to make sure they're working. 28 00:02:55 --> 00:02:57 We'll see a few more of these soon. 29 00:02:58 --> 00:03:04 We'll learn about the increment arithmetic operator which increments by 1 but I'll use that a little later. 30 00:03:05 --> 00:03:08 So, practice these and make sure you learn them well. 31 00:03:09 --> 00:03:14 Thanks for watching. This is Arvind dubbing for the Spoken Tutorial project.