Chapter 3

    1. int, possibly short or unsigned or unsigned short; population is a whole number.

    2. float; it's unlikely the average will be an exact integer. (You could use double but don't really need the extra precision.)

    3. char.

    4. int, possibly unsigned.

  1. One reason is that long may accommodate larger numbers than int on your system; another reason is that if you do need to handle larger values, you improve portability by using a type guaranteed to be at least 32 bits on all systems.

    1. char constant (but stored as type int)

    2. int constant

    3. double constant

    4. unsigned int constant, hexadecimal format

    5. double constant

  2. Line 1: Should be #include <stdio.h>.

    Line 2: Should have a pair of parentheses containing void following main; that is, main(void).

    Line 3: Use {, not (.

    Line ...

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.