Whats the differences of prefix and postfix | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Whats the differences of prefix and postfix

15th Mar 2017, 10:44 PM
Desiree Guillen
Desiree Guillen - avatar
3 Answers
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 :)
16th Mar 2017, 5:40 AM
Hussain Al-Umran
Hussain Al-Umran - avatar
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).
18th Mar 2017, 2:42 AM
Joe Fabian
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
2nd Apr 2017, 7:10 PM
Mikhail
Mikhail - avatar