[MUSIC] In this segment, we're going to talk about expression evaluation. C is a language rich with operators. And it's very important to know how the operators allow combination, in what order they're applied. I'm going to show you some very simple cases so you can get the central idea. And the central idea is going to be know how the operator works, know its precedents and know its associativity. So we're going to start with three very simple variables. As we declare them in C, we would say int a is initialized to 1, equals n and declaration is the initializer symbol. Int b is initialized to 2,and int c is left uninitialized, normally most systems would make that 0. So we have three variables to work with in our code. Here's a very simple expression using those. C is this equals means assigned. So in this case, we are seeing an assignment statement. Read that as c is assigned the expression a plus b semicolon is a and of the operation. So it's signaling what's called a sequence point and the computation. Everything that happens happens on that line and then you're finished and then you go on to the next line. Now as we know, a was initialized to 1, b was initialized 2, so, we would expect c to become 3. So this is a assignment expression. Inside it is a binary plus operator, and that says C is assigned a value of, and here we use parentheses a + b. And parentheses are critical in the C language when you're evaluating expressions, because they always override any other part of the expression's precedence. So they clearly show, if you are confused otherwise or it's a very complicated expression, that this is how you want the order of evaluation to occur. So as we just said, c becomes 3, that should be straightforward. Let's go on. Precedence, when we have something like 16 levels of precedence in C operators, things that are very low precedents, for example, tend to happen later or last. So assignment itself as an operator has very low precedence. However certain operations like unary operations, like the operation negation which is found when you're doing some logical expressions, and we'll use the exclamation point, is a very high precedence operator. As is something like auto increment or auto decrement, which are operators that use the symbol plus plus and minus minus. And then somewhere in the middle our arithmetic operators, and in the arithmetic operators, you have multiply for example, which in this case is featured with this star. And that has a higher precedence than simpler arithmetic operations plus and binary minus. By the way, note that you can also have unary minus and unary plus, and the only reason you would know the difference is context or parenthesization. And a unary operator like these are higher than the corresponding binary plus and minus. So binary plus or minus, they do two arguments, unary takes one argument. And then times, and indeed things like multiply and divide are higher precedence again. And there's also on that level the remainder operator percent, which again or sometimes called the modulo operator remainder operator, which is also a higher precedence equivalent to a multiply or divide then the addition operator or subtraction operator. Why is that important? Because if these get mixed up in an expression, you have to know which goes first. The other thing you need to know about is associativity. How do the operators associate? So when you have an operator a plus b plus c, this has got two operators, which goes first? Do you apply b plus c first and then do a? Or do you do a plus b first and then c? And It turns out that these operators occur left to right. And the overwhelming number of operators are left to right. And we show the equivalent parenthesization here. So we would get a plus b parentheses plus C parentheses if we wanted to fully parenthesized this expression to make it clear what the implicit order of evaluation based on associativity. Now looking at this other expression, a assigned b assigned c assigned 3, we get right to left. That means the c assigned 3 occurs first, then the b is assigned that expression value, than the a is assigned. And what you would all end up with is everything would end up being 3. All right, try to absorb that, make sure you can write code of this kind and know how to evaluate it. And we're going to go on to more complex expressions with different operators involved. [MUSIC]