Introduction to Primitive Data Types
In this tutorial, we will learn about the basic types of data that the C programming language offers.
In this tutorial, we will learn about the basic types of data that the C programming language offers.
C has 5 primary data types:
We will explore each of these data types in more depth shortly. However, before that, let’s take a brief overview of how these data types are categorized and the specific format they use to represent values and their range.
Data Types | Memory Requirements | Format Specifier | Range |
---|---|---|---|
short int | 2 bytes = 16 bits | %hd | -32768 to +32767 |
int | 4 bytes = 32 bits | %d | -2147483648 to +2147483647 |
long int | 4 bytes = 32 bits | %ld | -2147483648 to +2147483647 |
long long int | 8 bytes = 64 bits | %lld | -9223372036854775808 to +9223372036854775807 |
unsigned short int | 2 bytes = 16 bits | %hu | 0 to 65535 |
unsigned int | 4 bytes = 32 bits | %u | 0 to 4294967295 |
unsigned long int | 4 bytes = 32 bits | %lu | 0 to 4294967295 |
unsigned long long int | 8 bytes = 64 bits | %llu | 0 to 18446744073709551616 |
signed char | 1 byte = 8 bits | %c | -128 to +127 |
unsigned char | 1 byte = 8 bits | %c | 0 to 255 |
float | 4 bytes = 32 bits | %f | 1.2E-38 to 3.4E+38 |
double | 8 bytes = 64 bits | %lf | 1.7E-308 to 1.7E+308 |
long double | 16 bytes = 128 bits | %Lf | 3.4E-4932 to 1.1E+4932 |
Now, let’s delve deeper into each of these data types and understand them better. We will also explore how to calculate the ranges as mentioned in the above table.
Leave a comment