S.no | Types | Data Types |
---|---|---|
1 | ABasic data types | int, char, float, double |
2 | Enumeration data type | enum |
3 | Derived data type | pointer, array, structure, union |
4 | Void data type | void |
The basic data types are integer-based and floating-point based. C language supports both signed and unsigned literals.
Integer Types : Integers are whole numbers with a range of variables supported by a particular machine.
Floating Point Data type : Floating Point numbers are stored with 6 digits of precision. Those are defined with keyword float. When the accuracy is not sufficient then the data type double can be used. Double gives a precession of 14 digits these known as double precession numbers. Still for a better process we can use long double which uses 80 bits.
The memory size of basic data types may change according to 32 or 64 bit operating system.
Let's see the basic data types. It size is given according to 32 bit OS.
Data Types | Memory Size | Range |
---|---|---|
char | 1 byte | −128 to 127 |
signed char | 1 byte | −128 to 127 |
unsigned char | 1 byte | 0 to 255 |
int | 2 byte | −32,768 to 32,767 |
signed int | 2 byte | −32,768 to 32,767 |
unsigned int | 2 byte | 0 to 65,535 |
short int | 2 byte | −32,768 to 32,767 |
signed short int | 2 byte | −32,768 to 32,767 |
unsigned short int | 2 byte | 0 to 65,535 |
long int | 4 byte | -2147483648 to 2147483647 |
signed long int | 4 byte | -2147483648 to 2147483647 |
unsigned long int | 4 byte | O to 42949667295 |
float | 4 byte | 3.4e-38 to 3.4 e+ 38 |
double | 8 byte | 1.7e – 308 to 1.7e+308 |
long double | 10 byte | 3.4e – 4932 to 3.4e+4932 |
Enumeration data type consists of named integer constants as a list.
It start with 0 (zero) by default and value is incremented by 1 for the sequential identifiers in the list.
Those data types which are derived from fundamental data types are called derived data types.
There are basically three derived data types.
1. Array : A finite collection of data of same types or homogenous data type.
2. String : An array of character type.
3. Structure : A collection of related variables same or different data types.
• Void is an empty data type that has no value.
• This can be used in functions and pointers.