Home / C Tutorial / What is Secondary Data Type?

What is Secondary Data Type?

1. Array:

It is a collection of data of similar data type.
e.g. Int num [5];

Reserve a sequence of 5 location of two bytes each for storing integers.

2. Pointer:

Pointer is a variable that stores the address of some other variable.
e.g. int *i;

The above statement declares i as pointer to integer data type.

3. Structure:

A structure is a collection of data of different data types under one name.
Struct employees
char Name[10];
int Age;
int Salary;

4. Union:

It is a collection of data of different types sharing common memory space.
e.g. Union item

int m;
float x;
char c;
} ;

5. Enumerated Data types:

This data types gives us an opportunity to invent your own data type and define what values the variable of this data type can take.
Example: enum colors

red, green, blue, cyan
colors foreground, background;

Here the declaration has two parts:

a) The first part declare the data type and specifies its possible values.
b) The second part declare variable of this data type.

Now we can give the values to these variables:


But remember we can’t use values that aren’t in the original declaration. Thus, the following declaration cause error.


Note: Secondary data type has been given in detail later.