Data types are keywords which are used to assign a type to a variable. Mainly there are two type of data type
- Basic data type
- Derived data type
Further we can divide basic data type in two categories
- Primary data type
- int
- char
- float
- double
- void
- Secondary data type – which is called modifier also.
- short
- long
- signed
- unsigned
Secondary data type is used to modified primary data type. See example below
int money;
short int money;
long int money;
signed char alphabet_1;
unsigned short int balance;
Derived data type are derived from basic data types
- array
- pointer
- structure
- enumeration
User defined data type are derived from basic data type
Syntax:
typedef data_type new_data_type
Example:-
typedef int own;
int age; -1
own age; -2
Here both 1 and 2 declarations are similar.