The word data type tells that it describes the type of data. We haven't yet studied variables, functions etc. Data type is used there to describe the type of data. C supports several different types of data, each of which may be represented differently within the computer’s memory. Below are 4 basic data types.
Data type | Description | Memory requirement | Value range |
char | single character | 1 byte | -128 to 127 |
int | integer quantity | 2 bytes | -32,768 to 32,767 |
float | floating-point number | 4 bytes | -2,147,483,648 to +2,147,483,647 |
double | double precision floating-point number | 8 bytes | 2.3E-308 to 1.7E+308 |
The above data types can be used in an extensive way by using qualifiers like signed,unsigned, short, long.
For example, int data type can be used as signed int or long int and char data type can be used as signed char or long char.
Signed int means it will consider the sign bit and it is same as normal int but in case of unsigned int the value range will be from 0 to 65,535.
Signed int means it will consider the sign bit and it is same as normal int but in case of unsigned int the value range will be from 0 to 65,535.
The char data type represents individual characters. Hence, the char type will generally require only one byte of memory. Actually char type is of integer type.
With most compilers, a char data type will permit a range of values extending from 0 to 255. Some compilers represent the char data type as having a range of values extending from -128 to +127. There may also be unsigned char data (with typical values ranging from 0 to 255), or signed char data (with values ranging from -128 to +127).
No comments:
Post a Comment