Data Types
A data type identifies the type of data which is stored in the variable such as integer, floating, character, etc.
There are following data types in C language.
Types | Data Types |
---|---|
Primary Data Type | int, float, char, double and void |
Derived Data Type | array, pointer |
User-defined Data Type | structure, union, enumeration |
Primary Data Type
C compilers support all these primary data types.
Data Type | Description |
---|---|
int | int data type is used to specify integer |
char | char data type is used to specify character. |
float, double | Both are used to denote floating point numbers. |
void | As the name suggests, it holds no value and is generally used for specifying the type of function or what it returns. If the function has a void type, it means that the function will not return any value. |
Derived Data Type
Some derived data types and its descriptions are given below:
Data Type | Description |
---|---|
array | array is used when we need a lot of variables to store similar type of data items. |
pointer | Pointers are used to store address. A multiplication symbol '*' (known as astrick) denotes pointer variable. Example: int*, float*, char* etc. |
User-defined Data Type
The data type which is defined by the programmer known as user-defined data type. By the help of given data types, a programmer can define a new type of identifier for variables.
Data Type | Description |
---|---|
structure | A structure is a collection of different type of data items. |
union | Programmers can define a union with different members, but only a single member can contain a value at a given time. |
enumeration | Enumeration is a special data type that consists of integral constants, and each of them is assigned with a specific name. "enum" keyword is used to define the enumerated data type. |