Data Types and Qualifier
Data Types and Qualifier
Example: 0, -5, 10
For example:
int id;
Here, id is a variable of type integer.
Similarly, int of 2 bytes, it can take 216 distinct states from -215 to
215-1. If you try to store larger number than 231-1,
i.e,+2147483647 and smaller number than -231, i.e, -2147483648,
program will not run correctly.
Floating types
Floating type variables can hold real numbers such as: 2.34, -9.382, 5.0
etc.
For example:
float accountBalance; double bookPrice;
Here, both accountBalance and bookPrice are floating type variables.
The size of float (single precision float data type) is 4 bytes. And the
size of double (double precision float data type) is 8 bytes. Floating
point variables has a precision of 6 digits whereas the precision of
double is 14 digits.
Character types
Qualifiers alters the meaning of base data types to yield a new data
type.
Size qualifiers
Size qualifiers alters the size of a basic type. There are two size
qualifiers, long and short. For example:
long double i;
There is another qualifier signed which can hold both negative and
positive only. However, it is not necessary to define
variable signed since a variable is signed by default.
An integer variable of 4 bytes can hold data from -2 ^31 to 2^31-1.
However, if the variable is defined as unsigned, it can hold data from
0 to 2^32-1.
It is important to note that, sign qualifiers can be applied to int and
char types only.