Data Types in C
Basic data types in C
There are very few data types provided by C.
C does not provide any data-type for storing text as the it is made up of individual characters.
Following table shows the basic data-types:
Data-type | Keyword | Storage size in bytes | Range | Use |
---|
Character | char | 1 | -128 to 127 | For storing characters. |
Integer | int | 2 | -32768 to 32767 | For storing integer numbers. |
Floating Point | float | 4 | 3.4E-38 to 3.4E+38 | For storing the floating point numbers. |
Double | double | 8 | 1.7E-308 to 1.7E+308 | For storing the big floating point numbers. |
Valueless | void | 0 | Valueless | |
In the above table we have a data-type called 'void' which has no value but is used in the following cases:- For specifying the return type of the function when the function returns no value.
- For specifying the parameters of the function when no arguments are accepted by the function from the caller.
- For creating generic pointers.
The unsigned and signed char is used for ensuring the portability of the programs which store the non-character data as char.
Following table shows the different signed and unsigned char:
Data-type | Storage size in bytes | Range |
---|
char | 1 | -128 to 127 |
unsigned char | 1 | 0 to 255 |
signed char | 1 | -128 to 127 |
int | 2 | -32768 to 32767 |
unsigned int | 2 | 0 to 65535 |
signed short int | 2 | -32768 to 32767 |
signed int | 2 | -32768 to 32767 |
short int | 2 | -32768 to 32767 |
unsigned short int | 2 | 0 to 65535 |
long int | 4 | -2147483648 to 2147483647 |
unsigned long int | 4 | 0 to 4294967295 |
signed long int | 4 | -2147483678 to 2147483647 |
float | 4 | 3.4E-38 to 3.4E+38 |
double | 8 | 1.7E-308 to 1.7E+308 |
long double | 10 | 3.4E-4932 to 1.1E+4932 |