Basic course of C language (ii) data types, variables, and operators (14)

Source: Internet
Author: User
Tags arithmetic arithmetic operators bitwise operators logical operators lowercase variables

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.