Back to course

Fundamental Data Types: Integers

C Language: 0 to Hero - The Complete Beginner's Guide

Lesson 6: Fundamental Data Types: Integers

Data types specify the type of data a variable can hold and the amount of memory it occupies.

The int Type

Integers are used to store whole numbers (positive, negative, or zero) without fractional parts.

The basic integer type is int. Its size is usually 4 bytes (32 bits), allowing it to store values typically from -2 billion to +2 billion.

Integer Type Qualifiers

C offers qualifiers to manage the size and sign of integers:

TypeDescriptionTypical Size (Bytes)
short intSmaller integer2
intStandard integer4
long intLarger integer4 or 8
long long intLargest integer (C99+)8

Signed vs. Unsigned

  • Signed (default): Can hold positive and negative numbers.
  • Unsigned: Can only hold non-negative numbers (0 and positive). This doubles the positive range but eliminates negative values.

c // Examples of declarations int age = 30; // Signed int unsigned int counter = 100000; // Only positive values short int small_number = -5; long long big_number = 9000000000LL; // Use LL suffix for long long

Note: The exact size of these types can vary slightly between different compilers and architectures, but the relationships (short <= int <= long <= long long) hold true.