Lesson 05·C Programming

Data Types

Specifying memory requirements and representation ranges for variables

Data Types in C

When we declare a variable in a program, we must inform the compiler about the type of data it will store. This dictates the memory space allocated and the operations allowed on the value.

Below is a comprehensive reference of the primary fundamental data types used in C programming, their format specifiers, memory sizes, and valid ranges.

Fundamental Data Types Reference Table

Standard 16/32-bit compiler data type specifications and format specifiers.
KeywordFormat SpecifierSize (Bytes)Data Range
char%c1 Byte-128 to +127
int%d2 Bytes-32,768 to +32,767
long int%ld4 Bytes-2,147,483,648 to +2,147,483,647 (-2³¹ to +2³¹ - 1)
unsigned int%u2 Bytes0 to 65,535
float%f4 Bytes-3.4e38 to +3.4e38
double%lf8 Bytes-1.7e38 to +1.7e38
long double%Lf12 – 16 Bytes-3.4e38 to +3.4e38

Practical Usage Notes

  • Use char for storing single ASCII characters or very small integers.
  • Use int for counting, index loops, and whole numbers.
  • Use float or double when high precision floating-point fractions are required.
  • Use unsigned specifiers when negative values are never expected, effectively doubling the positive range.