In C, every variable has a the associated data type. It describes the types of data—integer, character, floating-point, double, etc.—that the variable is capable of storing. Different memory requirements and particular operations can be carried out on different types of data. A collection of data with fixed values, meaning, and features is referred to as a data type.
In C, there are many types of data types, including:
Different categories of this Data Types
The "basic data types" in C are the basic data types integers, floats, characters, etc. that are used to represent simple values.
The integer data type stores whole numbers such as -1, 0, 42, etc.
The char data type stores single characters such as 'A', '1', and '$'. The character must be wrapped by single quotes and printed using the %c format specifier.
The float data type stores single-precision floating-point numbers, which can only represent decimal values with minimal precision. This data type has a size of 4 bytes, meaning it takes up 4 bytes of memory. It ranges from +/- 3.4E-38F to +/- 1.7E+308F, depending on the system's architecture.
In the C programming language, a derived data type is one that is formed by combining one or more basic or other derived data types.
An array is a collection of similarly typed elements stored in sequential memory locations. Multiple values of the same type can be stored and retrieved using a single variable name.
A pointer is a variable that keeps track of another variable's memory location. Pointers are used to access data indirectly by referencing its memory location, as well as to allocate memory dynamically.
A "structure" is a user-defined composite data type that combines variables from multiple data types under a single name. Complex data structures are created with it to represent real-world entities. To create a structure, use the struct keyword and define each of its members inside curly brackets.
In C, the union data type is a user-defined datatype that allows multiple data types to be stored in the same memory address. It is comparable to a structure, with one key difference: only one of its members can be active and hold accurate information at any given time.
In C, enumeration is a user-defined data type that consists of a finite collection of named integer constants. It is commonly used to represent a group of related items with unique names. To build an enum, use the enum keyword followed by the enum's name, with a comma between the enum components. To use the enum, you must first construct a variable for it.
When a function does not return a value or a pointer has a specific data type, C expresses this using the void data type. It is widely used in function declarations as a return type to indicate that the function does not return any values and instead executes a task without providing any results.
The size of the data types in C is set by the architecture's size, hence we cannot establish a universal data type size. The sizeof() operator in the C language allows you to check the size of data types.