1. Data type
In the Turbo C language, each variable must have its data type defined before it is used. Turbo C has the following types: integral (int), floating-point (float), character (char), pointer (*), Value-free (void), and struct (struct) and Union (union). The first five of these are the basic data types of turbo C, the latter two data types (structure and union) will be introduced in chapter fifth.
2.1 Integral type (int)
Description of the integer type
With different modifiers, the integer number has the following types;
The signed short int has a signed integer number description. short or int with a word length of 2
BYTE total 16-bit binary number, the range is -32768~32767.
Signed long int signed length integer description. Short long, word length is 4 bytes total
32-bit binary number, the range of the number is -2147483648~2147483647.
unsigned short int unsigned integer number description. shorthand for unsigned int, word length
is 2 bytes A total of 16-bit binary numbers, the range of which is 0~65535.
unsigned long int unsigned length integer description. Abbreviated to unsigned long, word length
is 4 bytes A total of 32-bit binary numbers, the range of which is 0~4294967295.
Definition of integer variable
You can define an integer variable with the following statement
int A, B; /*a, B is defined as a signed short integer variable * *
unsigned long C; /*c are defined as unsigned long integer variables.
Three, the integral type constant expression
There are three representations of integral constants according to the different systems of differentiation:
Decimal number: The number starting with a non 0
such as: 220,-560, 45900
Octal Number: The number starting with 0
such as: 06; 0106, 05788
Hexadecimal number: Number starting with 0 x or 0x
such as: 0X0D, 0XFF, 0x4e
In addition, you can add an "L" or "L" letter after an integer constant to indicate that the number is a long integer, such as 22l,0773l,0xae4l.
2.2 Floating-point type (float)
First, floating point description
The following two types of floating-point numbers are available in Turbo C:
float floating-point number. The word length is 4 bytes and a total of 32-bit binary numbers, the range of which is 3.4x10-38e~3.4x10+38e.
Double floating-point number. The word length is 8 bytes and a total of 64-bit binary numbers, the range of which is 1.7x10-308e~1.7x10+308e.
Note: Floating-point numbers are signed floating-point numbers, and there are no unsigned floating-point numbers.
Second, the definition of floating point variable
You can define floating-point variables with the following statements:
float A, F; /*a, F is defined as a single floating-point variable *
Double b; /*B is defined as a double floating-point variable *
Third, floating point constant representation
For example: +29.56, -56.33, -6.8e-18, 6.365
Description
1. A floating-point constant has only one system (decimal).
2. All floating-point constants are by default double.
3. A floating-point number whose absolute value is less than 1, and 0 of the preceding decimal point can be omitted. For example: 0.22 can be written as. -0.0015E-3 can be written as-.0015e-3.
4. Turbo c default format to output floating-point numbers, only six digits after the decimal point.