C Datatypes
What are C Datatypes?
Whenever we use variables in C we have to specify its datatype to let the compiler to know what type of variable needs to know what type of data is going to be entered. this will make the compiler allocate the same memory size that variable will allocate.
Following are the main features that describe more about datatypes.
- A data type is a label or name for a set of variables.
- Data types are used to define the types of data being stored and manipulated
- The data type specifies the range of values that a variable can hold and how that information is stored in computer memory.
- C supports three types of data types.
- Primary fundamental or built-in or basic data type:
Primary datatypes are those data types which are fundamental in nature. The examples of primary datatypes are int, float, double, char, bool, enum. - Derived data type:
Derived datatypes in C are those data types which are generated by grouping and twisting the primary datatypes. The examples of derived datatypes are array, structure, pointer, function, and atomic types. - User-defined data type:
User-defined datatypes in C are those data types which are defined by us to create our own datatypes which are based on the standard ones. We can define our own datatypes by using different mechanisms. They are by using typedef, structures, and functions.
Primary fundamental or built-in/basic data type:
Data Type | Keyword | Range of values | Format Specifies | Storage capacity |
1.Character | char | -128 to +128 | % c | 1 byte |
2.Integer | int | -32768 to +32767 | %d or %i | 2 byte |
3.Floating point | float | 3.4e-38 to 3.4e38 | %f | 4 byte |
4.Double precise Floating point | double | 1.7e-308 to 1.7e308 | %d | 8 byte |
5. Void | void |