1. ## C interview tips

Some notes and interview tips...

2. Yup. Whoever wrote that failed the interview.

3. @Dave_Sinkula
Can you please explain what you mean by that.
We should rather use relevant comments on the forum

4. A mixture of beginner mistakes, undefined behavor, and outright flaws, it demonstrates that the one posting it has a novice level of C understanding.

5. Aside from the notes being pretty irrelevant for an interview, it contains at least one factual error:
Sign of Mod Division - Result is always the sign of first operand.

Example -14 &#37; 3 = -2

-14 % -3 = -2

14 % -3 = 2
I could have sworn I recently read that the sign of the result of modulus is undefined by the standard. For that section, it could have simply been "Read the standard".

6. From K&R2, page 205:

The binary / operator yields the quotient, and the % operator the remainder, of the division of the first operand by the second; if the second operand is 0, the result is undefined. Otherwise, it is always true that (a/b)*b + a%b is equal to a. If both operands are non-negative, then the remainder is non-negative and smaller than the divisor; if not, it is guaranteed only that the absolute value of the remainder is smaller than the absolute value of the divisor.

Edit: I just read the following at http://www.ibm.com/developerworks/po...ry/pa-ctypes1/:

Another avenue of potential variance is handling of division. The rules for division and remainder on positive numbers are fairly well defined. C89's requirements for division and remainder on negative numbers were simply that (x/y)*y+(x%y)==x. This leaves open an ambiguity. It's obvious that -5/5 is -1. What's not obvious is how to handle -3/5. Should it be -1, with a remainder of 2, or should it be 0, with a remainder of -3? Both results have been generated by real-world processors. In C99, the decision was made to require truncation towards 0; -3/5 is 0, with a remainder of -3. This imposes additional work on some processors.