Operator precedence
| Code | |
|
|---|---|---|
| Result | 5 |
17 |
No. 50
Miraculous addition
|
Q: |
Consider:
This is strange: 0L + max + 1 differing from max + 1 + 0L violates the commutative law know from algebra. And why does adding 0 makes a difference in the first place? Explain these three outcomes. |
||||||||
|
A: |
|
| Code | |
|---|---|
| Result | 9 |
|
|
No. 51
Evaluating a sum
|
Q: |
Consider:
Explain these two different outcomes. |
||||||
|
A: |
We consider the evaluation order for both snippets:
|
| Code | |
|
|---|---|---|
| Result | 14 |
Get the vibe |
| Code | |
|---|---|
| Result | No. of groups: 44 |
-
Converting the
intvalue of44into a string "44". -
Concatenating the two strings
"No. of groups: "and"44"into"No. of groups: 44".
