DataType in C
DataType in C Language
Data type is a keyword used to identify type of data. Data types are used for storing the input of the program into the main memory (RAM) of the computer by allocating sufficient amount of memory space in the main memory of the computer.
In other words data types are used for representing the input of the user in the main memory (RAM) of the computer.
In general every programming language is containing three categories of data types. They are
- Fundamental or primitive data types
- Derived data types
- User defined data types
Primitive data types
These are the data types whose variable can hold maximum one value at a time, in C language it can be achieve by int, float, double, char.
Example
int a; // valid a = 10,20,30; // invalid
Derived data types
These data type are derived from fundamental data type. Variables of derived data type allow us to store multiple values of same type in one variable but never allows to store multiple values of different types. These are the data type whose variable can hold more than one value of similar type. In C language it can be achieve by array.
Example
int a[] = {10,20,30}; // valid int b[] = {100, 'A', "ABC"}; // invalid
User defined data types
User defined data types related variables allows us to store multiple values either of same type or different type or both. This is a data type whose variable can hold more than one value of dissimilar type, in C language it is achieved by structure.
Syntax
struct emp { int id; char ename[10]; float sal; };
In C language, user defined data types can be developed by using struct, union, enum etc.