5. Operator
The operators of Turbo C are very rich and fall into three main categories: arithmetic operators, relational operators and logical operators, bitwise operators. In addition, there are operators to accomplish special tasks. The following are described separately.
5.1 Arithmetic operators
The arithmetic operators of Turbo C are as follows:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
operator function
────────────────────────────
+ Plus, one eye take positive
-Minus, one eye to take the negative
* Multiply
/except
% modulo
--minus 1
+ + plus 1
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
One or one mesh and two mesh operation
One-eye operation refers to the operation of an operand. For example:-A is a one-eye negative operation on a.
A binary operation (or a multiple-eye operation) is an operation of two operands (or operands).
In Turbo C, the addition, subtraction, multiplication, addition, modulo operation is the same as other advanced languages. You need to be aware of division and modulo operations.
For example:
15/2 is 15 divided by 2 quotient of the integer part 7
15%2 is 15 divided by 2 of the remainder part 1
For the modulo operator "%", it cannot be used for floating-point numbers.
In addition, since the number of characters in Turbo C is automatically converted to an integer, the number of characters can also participate in the two-mesh operation.
For example:
Main ()
{
char m, N; /* Define character variable * *
M= ' C '; /* Assign a small letter ' C ' to M
n=m+ ' A '-' a '; /* Converts lowercase letters in C to uppercase ' B ' and assigns them to n*/
...
}
In the example above, m= ' C ' is m=98, because the ASCII values of letters A and A are 65 and 97, respectively. This turns lowercase letters into uppercase letters, whereas if you want to turn uppercase letters into lowercase letters, you can use c+ ' a '-' a ' to calculate them.