Basic Data Types in C language

Length/SignSigned
Negative and positive
Unsigned
Only non-negative
No Length
Default sizes: int(32), char(8), float(32), double(64)
short
For 16-bit integers
long
For extended size integers/doubles
long long
64-bit

* The void type is not signed or unsigned because it doesn't represent a value at all. This type in C is a special type used to indicate no data.

** char can be either signed or unsigned by default, depending on the platform or compiler.
If you need to ensure signedness, use signed char or unsigned char.


The table outlines C language primitive data types and their modifiers.
The key feature is the systematic way the table shows how four primitive types (int, char, float, double) can be modified with length and sign qualifiers to create different variations with specific memory sizes and value ranges.
The signed/unsigned distinction is just one aspect of this broader classification system.
The main axis shows how the basic types (int, char, float, double, void) can be modified using length qualifiers (short, long, long long) and sign qualifiers (signed/unsigned). The left column categorizes these by bit length, from default sizes through 16-bit (short), extended size (long), to 64-bit (long long).
Hover over and click on each specific data type to read more.








Basic Types in C

C programming language provides several fundamental data types that serve as building blocks for more complex types. They define how data is stored and manipulated at the lowest level.



The int type in C is the most widely used core type for working with whole numbers. It is the first go-to for most numeric operations—flexible, reliable, and simple.
By default, it’s signed, meaning it can handle both positive and negative values, making it versatile for most tasks.
In terms of size, int is typically 4 bytes (32 bits) on modern systems, but keep in mind that its size can vary depending on the platform. For instance, it could be 2 bytes on older 16-bit systems. This variability means you should always be mindful when writing cross-platform code.

General Properties:
•Usually 32 bits (4 bytes) on modern systems;
•Default signed (-2,147,483,648 to 2,147,483,647);
•Can be unsigned (0 to 4,294,967,295);

int is perfect for everyday use cases like:
Counting: Keeping track of loops, iterations, or indices,size measurements and Error codes.
Arithmetic: Adding, subtracting, or doing any kind of number crunching.
Flags: Representing states or options with small values.

Best practices:
•Use for general integer arithmetic
•Prefer over other types unless specific size needed
•Check for overflow in critical calculations
•Consider unsigned for array sizes/positive-only values
•When working with int, always check its actual size on the target platform

The int type in C is at the core of understanding how other primitive types function. It serves as the reference point for variations like short, long, and unsigned. These are all essentially just tweaks to int—adjusting its size or the way it handles positive and negative values. For instance, short gives you a smaller range to save memory, while unsigned drops negatives altogether to double the positive range.

But the importance of int goes beyond its relation to other primitive types. It’s deeply tied to how more complex types like pointers, arrays, and structs operate. For example, when working with arrays, the size and indexing of elements are typically handled using int. Similarly, when you pass a pointer to a function, it’s often an int pointer when dealing with numeric data. Even structures, which are used to create complex data models, often contain int members as fields to represent quantities, counters, or status codes.

In many ways, int is the building block that bridges the gap between primitive simplicity and the complexity of higher-level constructs. By mastering its properties—its size, range, signedness, and behavior—you’re laying a solid foundation for understanding how data is stored, accessed, and manipulated in C. Whether it’s managing an array of integers or navigating a memory block with pointers, a firm grasp of int will make everything else much clearer. It’s not just a type—it’s a fundamental part of how C works.

int

Length Qualifiers

Sign Qualifiers

Short

Long

Long Long

Signed

Unsigned

short int (16-bit)

long int (32/64-bit)

long long int (64-bit)

signed int (-2B to +2B)

unsigned int (0 to 4B)




The char type in C is the smallest data type, typically occupying 1 byte (8 bits). It is primarily designed to store characters (like letters, digits, or symbols) using their corresponding numeric values in character encoding standards like ASCII. However, it can also be used as a small integer type due to its numerical representation.














Unsigned Integer: Modified int that only stores non-negative values from 0 to 4,294,967,295. Uses the sign bit for value, doubling the positive range.


Unsigned Character: 8-bit type storing values 0 to 255. Often used for byte manipulations and when full positive range is needed.


Short Integer: Smaller integer type, typically 16 bits. Range -32,768 to 32,767. Used when memory conservation is important.


Unsigned Short Integer: 16-bit type storing values 0 to 65,535. Used for small positive numbers when memory is constrained.


Long Integer: Extended integer type, 32 or 64 bits depending on system. Minimum range -2,147,483,648 to 2,147,483,647.


Unsigned Long Integer: Extended unsigned type, storing only non-negative values. Minimum range 0 to 4,294,967,295.


Long Double: Extended precision floating-point type. Size and precision are platform dependent but typically larger than double.


long-long-int.


unsigned-long-long-int

↑ TopNext →