++ experiments

#include <stdio.h>  
int main()  
{  
    int a = 4;  
    printf("a=4\n");  
    printf("(a)*(++a)=%d\ta=%d\n",(a)*(++a),a);  
    a = 4;  
    printf("(++a)*(++a)=%d\ta=%d\n",(++a)*(++a),a);  
    a = 4;  
    printf("(a++)*(a++)=%d\ta=%d\n",(a++)*(a++),a);  
    a = 4;  
    printf("(a++)*(a)=%d\ta=%d\n",(a++)*(a),a);  
    scanf("%d",&a);  
} 

Disassembly:

0_1297406426Hr1g.gif

Screenshot operating results:

0_1297406273Zpgx.gif

The results show that, if an expression preincrement symbol exists, first increment operation are sequentially performed, then since the value calculated by the expression. For example, when a = 4 (a) * (++ a) is equal to 25 instead of 4 * 5 = 20. Post increment symbol Similarly, the first calculation expression with the value of the original value, the last increment sequentially performed operations.

Ju Master said  Today you Ju Master said that?

Reproduced in: https: //www.cnblogs.com/mashang/archive/2011/03/24/1993509.html

Guess you like

Origin blog.csdn.net/weixin_34006965/article/details/94160868
Recommended