C language ++ --

Source: Internet
Author: User

 

 

 

 

 

 


The answer to this question is: 120

I didn't understand what c = 12 was?

 

 

A ++ is the first operation in the auto-Increment

++ A is the First Auto-incrementing operation.

For example, B = a ++ and B = ++ a. If a = 10, B is 10 and 11 respectively.

 

 

 

 

 

 

 

 

B = a ++ here, assign a value first. In ++, assign a to B, B = 10, a to auto-increment, a = 10 + 1 = 11

 


C = ++ a here, first ++, In the assignment, a auto-increment, a = 11 + 1, assign a to c, c = 12

 

 

 

D = 10 * a ++ here, it depends on the computing priority... ++ The auto-increment operator has a higher priority than the = value assignment operator... D = 10 * a ++... A ++, the first operation is auto-increment, a * 10 = 120, a auto-increment, a = 13

 

 

 

Int main (int argc, const char * argv [])
{

Int a, d;
A = 10;
 
D = 10 * (a ++ );
Printf ("a = % d, d = % d \ n", a, d );

D = 10 * a ++;
Printf ("a = % d, d = % d \ n", a, d );

Return 0;
}

Print:

A = 11, d = 100
A = 12, d = 110.


--------------

 

 

Int a, d;
A = 10;


D = 10 * (a ++ );
Printf ("a = % d, d = % d \ n", a, d );

Printing: a = 11, d = 100

 


Int a, d;
A = 10;


D = 10 * a ++;
Printf ("a = % d, d = % d \ n", a, d );

 

 

Printing: a = 11, d = 100

 

 

 

Although the printed results are the same, it depends on whether the operation is auto-incrementing first or not.


-----------

 


# Include <stdio. h>

Int main (int argc, const char * argv [])
{

Int a, d;
A = 10;
D = 10 * (++ );
Printf ("a = % d, d = % d \ n", a, d );

 

Return 0;
}

 

Print:

A = 11, d = 110

------------------

 

Detailed list of operators in C Language

 

 

For operators with the same priority, the operation order is determined by the combination direction.

Note :! > Arithmetic Operators> Relational operators >&>||> value assignment operators

 

 


 

 

 

 

 

 

-----------

 

 

 

-

 


Print result ::

 

 

--------------
 

 


 

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.