Before C can store a value, it must know what kind of value it is: a whole number, a character or a number with a fraction. The data type decides how much memory is used, which values fit, and which operations are allowed. This section covers the basic types, their real sizes on today’s computers, and the modifiers that change them.
What a data type tells the compiler
C has four basic data types:
Type
Stores
Example values
char
One character (stored as a small integer code)
'A', '7', '\n'
int
Whole numbers
-42, 0, 2026
float
Real numbers, single precision (about 6 significant digits)
3.14f, -0.5f
double
Real numbers, double precision (about 15 significant digits)
3.14159265358979
C also has void (no value, used with functions) and, since C99, _Bool for true/false values.
Sizes and ranges on a real system
The C standard fixes only minimum sizes. The actual size depends on the compiler and processor. Almost all 64-bit Linux and macOS systems use the same model, called LP64, where long and pointers are 64 bits.
Type
Standard minimum
16-bit DOS compilers
64-bit Linux / macOS (LP64)
Range on LP64
char
8 bits
1 byte
1 byte
−128 to 127 (signed) or 0 to 255
short
16 bits
2 bytes
2 bytes
−32,768 to 32,767
int
16 bits
2 bytes
4 bytes
−2,147,483,648 to 2,147,483,647
long
32 bits
4 bytes
8 bytes
about ±9.22 × 10¹⁸
long long
64 bits
—
8 bytes
about ±9.22 × 10¹⁸
float
—
4 bytes
4 bytes
about ±3.4 × 10³⁸, 6 significant digits
double
—
8 bytes
8 bytes
about ±1.8 × 10³⁰⁸, 15 significant digits
For signed integer types of n bits, the range is
−2n−1 to 2n−1−1
and for unsigned types it is 0 to 2n−1. The extra bit that a signed type uses for the sign is used for magnitude in an unsigned type, which is why the unsigned maximum is about twice as large.
Modifiers: short, long, signed, unsigned
The words short, long, signed and unsigned modify the basic types:
Combination
Meaning
short int, long int, long long int
Smaller or larger integer types (int may be omitted: short, long)
unsigned int, unsigned char
Non-negative only; the whole range is used for magnitude
signed char
A character type that is definitely signed
long double
Extended-precision floating type
There is no short float, unsigned float or unsigned double. Separately, C has true type qualifiers: const (the value must not be changed after initialisation) and volatile (the value may change outside the program’s control, for example hardware registers).
Key takeaways
The basic types are char, int, float and double; sizes depend on the system.
On 64-bit Linux and macOS: int 4 bytes, long 8 bytes, float 4 bytes, double 8 bytes.
Signed n-bit range: −2n−1 to 2n−1−1; unsigned: 0 to 2n−1.
short, long, signed and unsigned modify integer types; const and volatile are the qualifiers.
Practice questions
Answer on paper first, then check. The explanation matters more than the letter you chose.
Question 6 · short answer
Using the formula, find the range of a 32-bit signed integer and of a 32-bit unsigned integer.
Show worked answer
Signed: −231 to 231−1. Since 231=2,147,483,648, the range is −2,147,483,648 to 2,147,483,647. Unsigned: 0 to 232−1. Since 232=4,294,967,296, the range is 0 to 4,294,967,295.
MCA Online notes are made for reading on screen. Open https://mcastudy.online/mcs-201/data-types-operators-and-expressions/data-types-and-their-sizes/ to read this page.