The data type determines a set of values that a variable can have and the possible operations that can be performed on these values. For the declaration of each variable, we have to attach some data types.
The data type defines:- the amount of storage allocated to variables, the values that they can accept, and the operations that can be performed on variables.
Data types can be divided into three types.
- Basic or Primitive data types.
- User defined data types.
- Derived data types.
1) Basic or Primitive data types:
The four basic data types and their corresponding keywords available in C are Character (char), Integer (int), Floating-point (float), and Double (double).
All the basic data types have a different range of values, a different format specifier that is given below in the table.
|Data Type||Range||Size(bytes)||Format Specifier|
|char||-128 to 127||1||c|
|int||-32768 to 32767||2||d|
|float||3.4e-38 to 3.4e+38||4||F|
|double||1.7e-308 to 1.7e+308||8||Lf|
|long int||-2147483648 to 2147483647||4||ld|
We can also apply modifiers to the basic data types and modifiers change the ranges, size, format specifier of basic data types these modifiers are Signed(signed), Unsigned(unsigned), Short(short), and Long(long).
2) User-defined data types:
The c language provides flexibility to the user to create new data types. These newly created data types are called user-defined data types. The user-defined data types are Structure, Union, and Enumeration.
3) Derived data types:
The data types which are derived from basic data types are called derived data types such as Arrays, Pointers, and Functions.
We will cover the derived and user-defined data types in upcoming tutorials.