In a C program, data types are used to specify the type of data held by a variable or type of data returned/accepted by a function. If you remember the HelloWord Program we wrote earlier, you might have noticed that the main function returns an 'int' type response, which represents numbers.
Datatypes in C can be categorised into following sections| Basic Data Types | These are the basic built-in data types of C Programming Language. They include 'int', 'char', 'float' and 'double' |
| Enumerated Types | These are the types which can hold only a specific set of values for the variables defined using them. Name of the datatype is 'enum' |
| Void Type | Type 'void' indicates lack of data. |
| User Defined | This includes the types that can be created by the programmer using the basic types. This includes 'struct', 'union', arrays and pointers |
Basic data types
Basic data types are the built-in data types supported by C language. You can find the explanation and usage of them below
- Char : This can be used to store a single character. It can hold only one byte of data.
char var = 'a';
In the above example, variable 'var' holds a single character 'a'. - Int: This data type can be used to hold integer type of data. It may use 2/4/8 bytes depending on the architecture of the platform you're running the program. If the platform is 16 bit, int data type will use 2 bytes. If platform is of 32 bit, int data type will use 4 bytes. If platform is of 64 bit, int will use 8 bytes. 'int' variable cannot hold a floating point number.