Operations and operators in C language and operators in C Language

Source: Internet
Author: User

Operations and operators in C language and operators in C Language
1. Operator priority and associativity 1. Priority

In the operator list, the higher the operator, the higher the priority.

 

2. associativity

If O is used to represent binary operators that require two operands, then the expression aObOc:

The left Union operator interprets the expression as (aOb) Oc [left Union]

The right Union operator interprets the expression as aO (bOc) [right Union]

Conclusion: When an operator with the same priority is encountered, the combination indicates whether the expression should be operated from left to right or from right to left.

 

Ii. Operator list

Priority

Operator

Form

Name

Associativity

1

()

X (y)

Function call Operators

Left

1

[]

X [y]

Subscript operator

Left

1

.

X. y

. Operator (period operator)

Left

1

->

X-> y

-> Operator (arrow operator)

Left

1

++

X ++

Post-incrementing Operator

Left

1

--

Y --

Post-decimal Operator

Left

2

++

++ X

Increment operator

Right

2

--

-- Y

Decimal front Operator

Right

2

Sizeof

Sizeof x

Sizeof Operator

Right

2

&

& X

Single Object operator & (addressing operator)

Right

2

*

* X

Single Object operator * (pointer operator)

Right

2

+

+ X

Single Object operator +

Right

2

-

-X

Single Object operator-

Right

2

~

~ X

~ Operator (bitwise complement operator)

Right

3

!

! X

Logical non-Operator

Right

3

()

(X) y

Type conversion Operator

Right

4

*

X * y

Binary operator *

Left

4

/

X/y

/Operator

Left

4

%

X % y

% Operator

Left

5

+

X + y

Binary operators +

Left

5

-

X-y

Binary operators-

Left

6

<

X <y

<Operator

Left

6

>

X> y

> Operators

Left

7

<

X <y

<Operator

Left

7

<=

X <= y

<= Operator

Left

7

>

X> y

> Operators

Left

7

> =

X> = y

> = Operator

Left

8

=

X = y

= Operator

Left

8

! =

X! = Y

! = Operator

Left

9

&

X & y

Bitwise AND operator

Left

10

^

X ^ y

Bitwise OR operator

Left

11

|

X | y

Bitwise OR operator

Left

12

&&

X & y

Logic and operators

Left

13

|

X | y

Logic or operator

Left

14

? :

X? Y: z

Conditional Operators

Right

15

=

X = y

Basic assignment operator

Right

15

+ =-= * =/= <=> = & = ^ = | =

 

Compound assignment operator

Right

16

,

X, y

Comma Operator

Left

 

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.