WEBVTT 1 00:00:01.002 --> 00:00:03.117 In this demo I'm going to enter some expressions in the 2 00:00:03.118 --> 00:00:05.229 CodePad and how they will be evaluated 3 00:00:07.001 --> 00:00:09.004 before I start I'm going to clear the CodePad 4 00:00:09.005 --> 00:00:11.224 because it still has some output from the previous demo. 5 00:00:11.229 --> 00:00:14.222 If I want to clear the CodePad, all I have to do 6 00:00:14.229 --> 00:00:18.118 is click compile and it clears. 7 00:00:19.117 --> 00:00:22.118 The expressions I enter are going to include some variables 8 00:00:22.221 --> 00:00:25.005 so lets declare those variables first 9 00:00:26.002 --> 00:00:30.113 I want to declare three Integer variables 10 00:00:31.226 --> 00:00:38.005 X, Y and Z. 11 00:00:39.117 --> 00:00:41.227 The expressions can contain values, 12 00:00:41.228 --> 00:00:43.225 variables and operators 13 00:00:44.007 --> 00:00:45.229 I'm going to start with an expression 14 00:00:46.000 --> 00:00:48.009 that contains a relational operator 15 00:00:48.228 --> 00:00:51.000 X is less than or equal to twelve 16 00:00:51.001 --> 00:00:52.221 note than when I enter an expression and 16 00:00:52.222 --> 00:00:54.117 want it to be evaluated 17 00:00:54.225 --> 00:00:58.002 I don't include a semi-colon at the end. 18 00:00:58.222 --> 00:01:00.114 That expression evaluates to a 19 00:01:00.115 --> 00:01:03.112 boolean value of true. 20 00:01:05.220 --> 00:01:08.111 The next expression simply multiplies 21 00:01:08.225 --> 00:01:10.220 the three variables together 22 00:01:11.002 --> 00:01:14.114 and evaluates to an Integer value. 23 00:01:16.223 --> 00:01:18.223 The next one's a bit more complicated 24 00:01:18.226 --> 00:01:21.227 and in fact its built up from two other expressions 25 00:01:22.116 --> 00:01:25.115 the first one Y is greater than three 26 00:01:25.221 --> 00:01:28.116 is combined using a conditional operator 27 00:01:28.117 --> 00:01:30.009 the and operator 28 00:01:30.222 --> 00:01:34.110 with Y is less than ten 29 00:01:34.228 --> 00:01:39.004 and that evaluates to false, another boolean value. 30 00:01:40.116 --> 00:01:42.226 That expression will only be true 31 00:01:43.003 --> 00:01:46.227 if Y is greater than three and Y is less than ten 32 00:01:47.118 --> 00:01:52.005 in other words if Y is in the range four to nine. 33 00:01:54.222 --> 00:01:58.116 Lets try an expression that combines arithmetic operators 34 00:01:58.118 --> 00:02:02.226 X plus three times Y 35 00:02:03.220 --> 00:02:06.222 and that evaluates to forty two 36 00:02:07.117 --> 00:02:09.112 because of operator precedents 37 00:02:09.113 --> 00:02:11.220 the multiplication operator is applied before 38 00:02:11.221 --> 00:02:14.001 the addition operator in this expression 39 00:02:14.006 --> 00:02:16.229 so three times Y is calculated first 49 00:02:17.004 --> 00:02:20.228 and then twelve the value of X is added onto that. 50 00:02:22.220 --> 00:02:24.112 If we want the addition to be done first 51 00:02:24.113 --> 00:02:27.000 we have to enclose that part of the expression 52 00:02:27.114 --> 00:02:31.116 X plus three in brackets and then multiply 53 00:02:32.009 --> 00:02:34.226 and that evaluates to a different result. 54 00:02:37.111 --> 00:02:40.117 Finally lets try one of the increment operators 55 00:02:41.006 --> 00:02:44.224 this expression increments the value of X 56 00:02:45.113 --> 00:02:49.003 and gives the incremented value now 13. 57 00:02:51.004 --> 00:02:53.112 Note that unlike in the previous expressions 58 00:02:53.113 --> 00:02:55.222 this operator has actually changed the value 59 00:02:55.223 --> 00:02:58.002 of the variable that its applied to 60 00:02:58.006 --> 00:03:00.225 and if I tried to see the value of X again 61 00:03:01.006 --> 00:03:04.222 I can see that it has actually changed to thirteen.