Data type defines the type of data a variable can hold. C language has some predefined set of data types to handle various kinds of data that we can use in the program. These data types have different storage capacities.
The different types of data types as classified below in C language.
They are the primitive or fundamental data types in C. They can be classified further as Integer(int
), floating point(float
), character(char
) and void
. The void
type specifies that no value is available. It is used in the situation when a function returns no value or it does not accept the parameters.
C language supports both signed and unsigned literals.
The memory size of the basic data types may change according to 32 or 64-bit operating system.
Let's see the basic data types. Its size is given according to 32-bit architecture.
Data Types | Memory Size | Range |
---|---|---|
char | 1 byte | −128 to 127 |
signed char | 1 byte | −128 to 127 |
unsigned char | 1 byte | 0 to 255 |
short | 2 byte | −32,768 to 32,767 |
signed short | 2 byte | −32,768 to 32,767 |
unsigned short | 2 byte | 0 to 65,535 |
int | 2 byte | −32,768 to 32,767 |
signed int | 2 byte | −32,768 to 32,767 |
unsigned int | 2 byte | 0 to 65,535 |
short int | 2 byte | −32,768 to 32,767 |
signed short int | 2 byte | −32,768 to 32,767 |
unsigned short int | 2 byte | 0 to 65,535 |
long int | 4 byte | -2,147,483,648 to 2,147,483,647 |
signed long int | 4 byte | -2,147,483,648 to 2,147,483,647 |
unsigned long int | 4 byte | 0 to 4,294,967,295 |
float | 4 byte | |
double | 8 byte | |
long double | 10 byte |
They are a twisted group of primary data types. For example, array
, structure
, union
and pointer
.
These data types are defined by the user. They can be of two types- Enum
and Typedef
.
Both Derived data types and User Defined data types will be discussed in detail in coming sections.