Basic operators and expressions in C Language

Source: Internet
Author: User

Basic operators and expressions in C Language
Types, priorities, and associativity of C Operators

There are many operators and expressions in C language, which are rare in advanced languages. It is precisely the rich operators and expressions that make the C language function perfect. This is also one of the main features of C language.

The operators in C language not only have different priorities, but also have a feature of their combination. In an expression, the order of computing operations involved in the operation must not only comply with the operator priority rules, but also be restricted by the combination of operators, to determine whether the operation is performed from left to right or from right to left. This combination is not available for operators in other advanced languages, so it also increases the complexity of the C language.

Types of operators C-language operators can be divided into the following types:

1. Arithmetic Operators

It is used for various numerical operations. Including addition (+), subtraction (-), multiplication (*), Division (/), remainder (or modulo operation, %), auto-increment (++) and auto-subtraction.

2. Relational operators

Used for comparison. Including greater than (>), less than (<), equal to (=), greater than or equal to (> =), less than or equal to (<=), and not equal (! =.

3. logical operators

Used for logical operations. Including and (&), or (|), non (!) Three.

4. bitwise Operator

The amount involved in the operation, which is calculated in binary bits. Including bitwise AND (&), bitwise OR (|), bitwise non (~) , Bitwise exclusive or (^), left shift (<), right shift (>.

5. Value assignment operator

Used for value assignment, including simple value assignment (=), compound arithmetic value assignment (+ =,-=, * =,/=, % =), and compound bit operation value assignment (& =, |=, ^ =, >>=, <<=) there are 11 types.

6. Conditional Operators

This is a three-object Operator Used for conditional evaluation (? :).

7. Comma Operator

It is used to combine several expressions into one (,).

8. pointer Operators

This operation is used to obtain the content (*) and the address.

9. Number of cell Operators

Used to calculate the number of bytes of the Data Type (sizeof ).

10. Special operators

There are several types of brackets (), subscripts [], and Members (→.

Related Article

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.