diff options
| author | mo khan <mo@mokhan.ca> | 2025-01-23 10:22:08 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-01-23 10:22:08 -0700 |
| commit | 7031e53d352b3b8cb7e9e403a48818ff585b6bc2 (patch) | |
| tree | c20a098be054aac19413e37c3fff385929d1c555 /assignments/4-solution.md | |
| parent | 69030c3e15ff79b1a2b40b97a2c418f6b3474697 (diff) | |
Complete question from chapter 11.
Diffstat (limited to 'assignments/4-solution.md')
| -rw-r--r-- | assignments/4-solution.md | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/assignments/4-solution.md b/assignments/4-solution.md index 43c7781..4a75011 100644 --- a/assignments/4-solution.md +++ b/assignments/4-solution.md @@ -21,4 +21,49 @@ first is bigger Chapter 11: +Figure 11.9 + +1. Identify the tokens in each of the following statements. (You do not need to classify them; just identify them.) + a. `if (a == b1) a = x + y;` + + | token | type | + | ----- | ---- | + | if | if condition | + | ( | left paren | + | a | symbol | + | == | comparison operator | + | b1 | symbol | + | a | symbol | + | = | assignment operator | + | x | symbol | + | + | addition operator | + | y | symbol | + | ; | statement terminator | + + b. `delta = epsilon + 1.23 - sqrt(zz);` + + | token | type | + | ----- | ---- | + | delta | symbol | + | = | assignment operator | + | epsilon | symbol | + | + | addition operator | + | 1.23 | floating point number | + | - | subtraction operator | + | sqrt | symbol | + | ( | left paren | + | zz | symbol | + | ) | right paren | + | ; | statement terminator | + + c. `print(Q);` + + | token | type | + | ----- | ---- | + | print | symbol | + | ( | left paren | + | Q | symbol | + | ) | right paren | + | ; | statement terminator | + Chapter 12: |
