|Prev [ 07.html ]||Data Types||Chapter 6||lab07 C/C++ Data|
|08||Expressions etc||Chapter 7||lab08 C/C++ Expressions|
|Next [ 09.html ]||Control structures||Chapter 8 not section 5||lab09 C/C++ Control|
Answer review questions on chapter 7.
Hand in answers to 2 or more review questions.
Note 1: Expressions are not Statements
Be careful to distinguish Expressions from Statements. Expressions are evaluated and return Values. Statements are executed and return a new State. Most languages have both.
Note 2: Precedence and Associativity
You may want to express precedence and associativity in your project.
These are syntax not semantics. Express precedence and associativity in BNF/EBNF/XBNF not in the UML. It takes some extra definitions. See sections 188.8.131.52, 184.108.40.206 and 220.127.116.11 in the book.
For example, suppose we might define
But this does not show the relative precedence of "+" and "*".
We show the precedence of "*" and "+" in algebra by replacing the above by:
To express associativity we can replace the '#' by recursion. For example:
Warning: it is unusual(and confusing) to have different associativities for multiplication and addition in a real language.