The difference is as follows:
x means that the value of x is incremented by 1 first, and then the value of x is calculated.
x is to first calculate the value of x, and then increase the value of x by 1.
Example:
int x=10; System.out.println(x++); System.out.println(x);
The first one outputs 10, x first uses the value of x in the current expression, and then increases the value of x by 1, and the second one outputs 11, because After the previous instruction, x has increased by 1.
int x=10; System.out.println(++x); System.out.println(x);
The first one outputs 11, x first increments the value of x by 1, and then uses the value of x in the current expression. The second one also outputs 11, and x increases after the previous instruction. 1.
Recommended tutorial:c language tutorial
The above is the detailed content of What is the difference between x++ and ++x in c language. For more information, please follow other related articles on the PHP Chinese website!