Chapter 3
int, possibly short or unsigned or unsigned short; population is a whole number.
float; it's unlikely the average will be an exact integer. (You could use double but don't really need the extra precision.)
char.
int, possibly unsigned.
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.
char constant (but stored as type int)
int constant
double constant
unsigned int constant, hexadecimal format
double constant
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access