‘C’ compilers support four fundamental data types. They are as follows −
- Integer
- Character
- Floating − point
- Double precision floating point
Primary Data Types
Integral data type
Integral data types are used to store whole numbers and characters.
It is further classified into two types −
- Integer data type.
- Character data type.
Integer data type
This data type is used to store whole numbers.
The integer storage are short int, int and long int in both signed and unsigned forms.
Integer Data Types | |||
---|---|---|---|
Type | size(in bytes) | Range | Control String |
short in (or) signed short int | 1 | -128 to 127 | %h |
unsigned short int | 1 | 0 to 255 | %uh |
int (or) signed int | 4 | -32768 to 32767 | %d or %i |
unsigned int | 4 | 0 to 65535 | %u |
Long int (or) signed long int | 4 | -2147483648 to 2147483647 | %ld |
Unsigned long int | 4 | 0 to 4294967295 | %lu |
Character data type
Character data type is used to store characters only.
These characters are internally stored as integers.
Each character has an equivalent ASCII value.
For example, ‘A’ has ASCII value 65.
Character Data Types | |||
---|---|---|---|
Type | Size(in bytes) | Range | Control String |
Char(or) signed Char | 1 | -128 to 127 | %C |
unsigned Char | 1 | 0 to 255 | %c |
Floating - point Data type
Floating point data types are used to store real numbers.
float’ is used for 6 digits of accuracy.
‘double' is used for 12 digits of accuracy.
More than 12 digits, ‘long double’ is used.
Floating Point Data Types | |||
---|---|---|---|
Type | size(in bytes) | Range | Control String |
float | 4 | 3.4E - 38 to 3.4 E + 38 | %f |
double | 8 | 1.7 E - 308 to 1.7 E + 308 | %lf |
long double | 16 | 3.4 E - 4932 to 1.1 E + 4932 | %Lf |