Data type in C language

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.

  1. Basic or Primitive data types.
  2. User defined data types.
  3. 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 TypeRangeSize(bytes)Format Specifier
char-128 to 1271c
int-32768 to 327672d
float3.4e-38 to 3.4e+384F
double1.7e-308 to 1.7e+3088Lf
long int-2147483648 to 21474836474ld

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.