Broadly, there are 5 different categories of data types in the C language, they are:
Data types in the C language
1. Basic Types
They are arithmetic types and are further classified into: (a) integer types and (b) floating-point types.
2. Enumerated types
They are again arithmetic types and they are used to define variables that can only assign certain discrete integer values throughout the program.
3. The type void
The type specifier void indicates that no value is available.
4. Derived types
They include (a) Pointer types, (b) Array types, (c) Structure types, (d) Union types and (e) Function types.
5. Bool Types
This is define the value 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 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.
C Datatype Value Range
In the table below we have the range for different data types in the C language.
Type |
Typical Size in Bits |
Minimal Range |
Format Specifier |
char |
8 |
-127 to 127 |
%c |
unsigned char |
8 |
0 to 255 |
%c |
signed char |
8 |
-127 to 127 |
%c |
int |
16 or 32 |
-32,767 to 32,767 |
%d, %i |
unsigned int |
16 or 32 |
0 to 65,535 |
%u |
signed int |
16 or 32 |
Same as int |
%d, %i |
short int |
16 |
-32,767 to 32,767 |
%hd |
unsigned short int |
16 |
0 to 65,535 |
%hu |
signed short int |
16 |
Same as short int |
%hd |
long int |
32 |
-2,147,483,647 to 2,147,483,647 |
%ld, %li |
long long int |
64 |
-(263 - 1) to 263 - 1 (Added by C99 standard) |
%lld, %lli |
signed long int |
32 |
Same as long int |
%ld, %li |
unsigned long int |
32 |
0 to 4,294,967,295 |
%lu |
unsigned long long int |
64 |
264 - 1 (Added by C99 standard) |
%llu |
float |
32 |
1E-37 to 1E+37 with six digits of precision |
%f |
double |
64 |
1E-37 to 1E+37 with ten digits of precision |
%lf |
long double |
80 |
1E-37 to 1E+37 with ten digits of precision |
%Lf |
What happens if the value is out of Range?
If you try to assign a value to any datatype which is more than the allowed range of value, then the C language compiler will give an error.