0
Whats the differences of prefix and postfix
3 Respuestas
0
prefix is to start building the math tree preparing it for testing and calculation calling in lexical analysis with operation like (+ a b)
postfix is the reverse tree is to start from operand then operation like (a b +)
but u know , I think, the most used one is the infix Wich the operation is in between like (a + b)
I hope I put it right :)
0
x++ show value of x, then increment
++x evaluate, increment x, then show the value
In both cases increment is happening, just the value that is displayed is different.
An example:
int a = 10; // a is 10
int b = ++x; //a is 11 and b is 11
the answer is b = 11;
(this is because the value of a = 10 and then it is incremented by 1, so 10+1=11).
But, if we have this example:
int a = 10; //a is 10
int b = x++; //a is 11 and b is 10
The answer is b = 10.
(this is because 'a = b' is evaluated with a=10, but a is still incremented a= 10 +1 So a is 11, but b is 10).
0
Joe Fabian you are right man. but fix examples:
int a = 10; // a is 10
int b = ++x; //a is 11 and b is 11
//int b = ++a, not x