Operator problems-priority

Source: Internet
Author: User
# Include <stdio. h> int main (INT argc, char * argv []) {unsigned char a = 0xa5; unsigned char B = ~ A> 4 + 1; printf ("% d", B); Return 0 ;}

Evaluate the output result.

This question is mainly about the operator priority.

Because> the priority is lower than +, the answer to this question is 250. (because a exists in a 16-bit register, it is not 2 ).

C language operator priority and tips

A total of 15 priorities:

1 () [].->

2! ~ -(Negative sign) ++ -- & (take the variable address) * (type) (force type) sizeof

3 */%

4 +-

5 >><

6 >>=<=

7 =! =

8 &

9 ^

10 |

11 &&

12 |

13? :

14 = + =-= * =/= % = | = ^ = & gt; = <=

15,

Parentheses are the first member. // brackets operator [] () member operator.->

Second for all single object; // All single object operators, such as ++, --, + (positive),-(negative), pointer operation *, & multiplication and division, and addition and subtraction; // This "remainder" refers to the remainder operation, that is, %

Shift 5, relation 6; // shift operator: <>>, relation: ><>=

Equals (and) to the seventh row; // that is, = and! =

Bitwise AND exclusive or bitwise OR; // these operations are bitwise operations: bitwise AND (&) exclusive or (^) bitwise OR (|)

"Three parts of the World" 80 or 90;

Logical or heel; // logical operator: | and &&

12 and 11; // attention sequence: Priority (|) at the bottom of priority (&&)

The condition is higher than the value assignment. // the priority of the Three-object operator is 13 BITs, which is only higher than the value assignment operator and ","

The lowest comma operation level! // The comma operator has the lowest priority.

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.