12.
why does B work? ceil(2.4) = 3, 3 % 2 = 1 which doesn't == 3. So it has something to do with the first part of the OR. Can anyone explain why that is true? |
It looks like you're not parsing the expression right. The expression is equivalent to
isFull = (isFull || ceil(2.4) % 2 + 1 == 3)
.
13. In integer arithmetic, 1/2=0. Therefore, 1/2*2=0. Therefore, 1/2*2+3=3.
15. Yes. It's called "casting". It means to explicitly convert a value from one type to another.
22. The function doesn't return anything. You can't print the value of nothing.
Unnumbered:
It's always possible to directly test the truth of a basic type such as int. Saying if (a) is the same as saying if (a!=0). Thus, if (x++ && y++) is the same as saying if (x++!=0 && y++!=0). Since x and y start as zero, the true block is not executed. After the comparison, x and y have been incremented, so x+y=2.
36. Despite the indentation, the second printing line is not included inside the true block of the if statement, so it executes regardless of the value of the condition.