Chapter 5

    1. 30

    2. 27 (not 3). (12 + 6)/(2*3) would give 3.

    3. x = 1, y = 1 (integer division)

    4. x = 3 (integer division) and y = 9

    1. 6 (reduces to 3 + 3.3)

    2. 52

    3. 0 (reduces to 0 * 22.0)

    4. 13 (reduces to 66.0 / 5 or 13.2, then assigned to int)

  1. Line 0: Should include <stdio.h>.

    Line 3: Should end in a semicolon, not a comma.

    Line 6: The while statement sets up an infinite loop because the value of i remains 1 and is always less than 30. Presumably we meant to write while(i++ < 8).

    Lines 6–8: The indentation implies that we wanted lines 7 and 8 to form a block, but the lack of braces means that the while loop includes only line 7. Braces should be added.

    Line 7: Because 1 and i are both integers, the result of the division will be 1 when i is 1, and 0 for all larger values. ...

Get C Primer Plus®, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.