I ++ and ++ I

Source: Internet
Author: User
  1. Write and judge whether the four expressions of ABCD are correct. If yes, write the value of A in the expression (3 points)
    Int A = 4;
    (A) A ++ = (a ++); (B) a ++ = (++ A); (c) (a ++) ++ = A; (d) (++ A) ++ = (a ++ );
    A =?
    A: C error. The left side is not a valid variable and cannot be assigned a value. You can change it to (++ A) + =;
    After the change, the answers are 9, 10, 10, and 11 in sequence.

 

Analysis:

A: It is equivalent to executing a + = A; A ++;

B: It is equivalent to executing a ++; A ++ =;

C: After modification, it is equivalent to executing ++ A; A ++ =;

Same as B

D: equivalent to execution ++ A; A ++ =;
A ++;

 

Summary rules: ++ A has the highest priority and is the first to execute

The second is to execute common operations.

A ++ has the lowest priority and is finally executed.

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.