C Data Types
Data types specifies a particular kind of data item defined by the values it can take. C provides various kinds of data types. Data types in C can be classified under 3 categories as given below:
- Built-in Data Types
- User Defined Data Types
- Derived Data Types
Built-in Data Types
C supports various built-in data types. They are given below in the table:
| Type | Storage size | Value range |
|---|---|---|
| char | 1 byte | -128 to 127 or 0 to 255 |
| unsigned char | 1 byte | 0 to 255 |
| signed char | 1 byte | -128 to 127 |
| int | 2 or 4 bytes | -32,768 to 32,767 or -2,147,483,648 to 2,147,483,647 |
| unsigned int | 2 or 4 bytes | 0 to 65,535 or 0 to 4,294,967,295 |
| short | 2 bytes | -32,768 to 32,767 |
| unsigned short | 2 bytes | 0 to 65,535 |
| long | 8 bytes | -9223372036854775808 to 9223372036854775807 |
| unsigned long | 8 bytes | 0 to 18446744073709551615 |
| float | 4 bytes | 1.2E-38 to 3.4E+38 |
| double | 8 bytes | 2.3E-308 to 1.7E+308 |
| long double | 10 bytes | 3.4E-4932 to 1.1E+4932 |
Another built-in data type is void. Two uses of void are to specify the return type of a function when it is not returning any value and to indicate an empty argument list to a function.
User Defined Data Types
There are three types of user defined data types.
| Data Types | Description |
|---|---|
| Structure | Structure is a package of variables of different types under a single name. It is need to handle data proficiently. struct keyword is used to define a structure. |
| Union | Union is use to store various data types in the same memory location. Programmers can define a union with various members, but only a single member can contain a value at a given time. |
| Enumerated | Enumeration is a special data type that provides a way for attaching names to number. The enum keyword automatically enumerates a list of words by assigning them values 0,1,2 and so on. This facility provides an alternative means for creating symbolic constants. |
Derived Data Types
Those data types which are derived from the fundamental data types and acts as a new data type are called derived data types. Function, arrays, and pointers are derived data types in C programming language.