Data Types in C Language:
C Language categorizes the data used by it into two:
1. Basic data types
2. Derived data types
Basic Data Types
The basic data types available in C are listed below ;
Data type Description
Int integer quantity
Char Single character
Float Floating point number
Double double precision floating point number
This represents an integer data type. An integer is a whole number : 0, 1, 2, -1, -2,-3, etc.
The character type is used to represent individual characters. Each char type has an equivalent integer representation. So a character is really a kind of integer. Since each ASCII character has an integer value in the range 0 to 255, a character can be interpreted as its integer value.
Real numbers are referred as float in C. They may be in the fractional or in the exponential form.
The type double is similar to type float. It is used if the accuracy provided by float variable is not sufficient. Variable declared as double type can store twice as much precision as represented by a float.
Qualifiers or modifiers
Some basic data types can be qualified by using the type qualifiers shor, long, signed and unsigned.
Qualifiers for int
Integer quantity can be qualified as short, long or unsigned.
A short int may require less memory than an ordinary int, but it will never exceed an ordinary int in word length.
Long int generally require twice the space in memory that an ordinary int requires.
Sometimes we know in advance that the value of a given integer variable will always be positive, in such cases we can declare that variable to be unsigned.
Qualifiers for character
Character data type can be qualified as either signed or unsigned. The range of unsigned character is form 0 to 255 and the range of signed char is form -128 to 127.
Qualifiers for double and float
With the floating point variable, the modifier long may be used for example, long float or long double. However, the meaning of these data types will vary from one compiler to another.
The following table shows the Basic data types with qualifiers as well as their memory requirements.
Type Bytes required Range
Char 1 0 to 255
Unsigned char 1 0 to 255
Signed char 1 -128 to 127
Int 2 -32768 to 32767
Unsigned int 2 0 to 65535
Long int 4 -2,147,483,648 to 2,147,483,647
Long unsigned int 4 0 to 4,294,967,295
Float 4 3.4E-38 to 3.4E+38
Double 8 -1.7E-38 to 1.7E+308
Long double 10 3.4E-4932 to 3.4E+4932
Derived Data Types.
Derived data types are buit from basic data types. C permits the following derived data types.
Array : Collection of elements, all of which are of same types.
Structure : Collection of elements of different types.
Union : Collection of elements of different types.
Typedef : User defined data type name.
The properties and use of these will be discussed in later chapters.