As the name suggests, a Datatype defines the type of data being used. Whenever we define a variable or use any data in the C language program, we have to specify the type of the data, so that the compiler knows what type of data to expect.
For example, you may want to use a number like 1, 2, 100, or a decimal point number like 99.95, 10.5, or a text, like “Studytonight”, all these values are handled differently by the C language compiler, hence, we use data types to define the type of data used in any program.
Broadly, there are 5 different categories of data types in the C language, they are:
|Basic||character, integer, floating-point, double.|
|Derived||Array, structure, union, etc.|
|Bool type||true or false|
C Primary Data types:
The C language has 5 basic (primary or primitive) data types, they are:
- Character – ASCII character set or generally a single alphabet like ‘a’, ‘B’, etc.
- Integer – Used to store whole numbers like 1, 2, 100, 1000, etc.
- Floating-point – Decimal point or real numbers values like 99.9, 10.5, etc.
- Double – Very large numeric values which are not allowed in Integer or Floating point type.
- Void – This means no value. This data type is mostly used when we define functions.
There are different keywords to specify these data types, the keywords are: