In C, data types are used to specify the data. The variety of data type available allows the program to select the type appropriate to the need of the application.

C language provides very few basic data types:

Type Data types
Basic Data Type int, char, float, double
Derived Data Type array, pointer, structure, union
Enumeration Data Type Enum
Void Data Type Void

 

Basic Data Types:

The Basic data types are used for storing arithmetic data into variables.

The basic data types are of 4 types:

  1. Integer: The integer (int) data type is used to store the numbers. The int data type can store data in the range of -32768 to 32767.
  2. Character: The char type is of one byte and is used to store the single character. C does not provide any data type for storing the text. This is because the text is made up of individual characters. The range of char is given as -128 to 127.
  3. Floating Point: It is used to store the floating point numbers (decimal). The range of a floating point number is given as 4E-38 to 3.4E+38
  4. Double: It is used to store big floating point numbers and range is given as 7E-308 to 1.7e+308.

Modifiers: These “short”, “signed”, “unsigned”, “long” is the modifiers which define the amount of storage allocated to the variable. This is followed by the ANSI rules as:

short intß int ß long int

Basic Data Types

Enumerated Data Types: The Data type which consists of named integer constant as a list. By default, it starts at 0 and sequentially increased by 1. It is user defined data types and is used to make the problem easy to read by assigning the names to the integral constant.

Example:

enum states {active=1, inactive=0};

enum month { jan, feb, mar, apr, may, jun, jul, aug, sept, nov, dec };

int main()

{

Enum month mon;

mon= jan;

printf(“%d”, mon);

return 0;
}

Derived Data Types: The derived data types are array, structure, union, pointers which is also known as non primitive data types.

We’ll learn about derived data types in this tutorial.

Void Data Type: It has no value and also known as the empty data type. This is mostly used in pointers and functions.

Void Data Type