All high-level programming languages support the concept of data types. A data type defines a set of values that a variable can store along with a set of operations. Data types are used to store various types of data which is managed by program. Data type attaches with variable to determine the number of bytes to be allocate to variable and valid operations which can be performed on that variable. Although C has several built-in data types, it is not a strongly typed language, as are Pascal and Ada. C supports various data types and here some common data type as character, integer and floating-point types.
C defines five foundational data types as defined below:
It is significant to realize that C stipulates only the minimal range of each data type, not its size in bytes.
The exact format of floating-point values will depend upon how they are implemented. Variables of type char are generally used to hold values defined by the ASCII character set. Values outside that range may be handled differently by different compilers. The range of float and double will depend upon the method used to represent the floating-point numbers. Standard C specifies that the minimum range for a floating-point value is 1E–37 to 1E+37. The minimum number of digits of precision for each floating-point type is shown in Table.
The type void either explicitly declares a function as returning no value or creates generic pointers. Both of these uses are discussed in subsequent chapters.
All Data Types Defined by the C Standard
|Bits |Minimal |Range |
|Char |8 |–127 to 127 |
|unsigned char |8 |0 to 255 |
|signed char |8 |–127 to 127 |
|int |16 or 32 |–32,767 to 32,767 |
|unsigned int |16 or 32 |0 to 65,535 |
|signed int |16 or 32 |Same as int |
|short int |16 |–32,767 to 32,767 |
|unsigned short int |16 |0 to 65,535 |
|signed short int |16 |Same as short int |
|long int |32 |–2,147,483,647 to 2,147,483,647 |
|long long int |64 |–(263 –1) to 263 –1 (Added by C99) |
|signed long int |32 |Same as long int |
|unsigned long int |32 |0 to 4,294,967,295 |
|unsigned long long int |64 ...