0

What is a difference between x++ and ++x???

22nd Nov 2016, 10:15 PM
Ed01
2 Answers
+ 1
You Mean Prefix and Postfix The prefix ++x ( rise the value then use it) form first performs the increment operation and then returns the value of the increment operation. The postfix x++ (use it then rise the value) form first returns the current value of the expression and then performs the increment operation on that value. For example: int count=1; System.out.println(++count); >> this displays 2 int count=1; System.out.println(count++); >> this displays 1
22nd Nov 2016, 10:23 PM
( ͥ° ͜ʖ ͥ°)
+ 1
try it in a code like this i dont know c++ but in java javascirpt if x is 1 a=++x; // x incroment BEFORE "a" get the value now a is 2 and x = 2 if x is 1 a=x++; // x incroment AFTER "a" get the value now a is 1 and x = 2 but try it i cold flip this around
22nd Nov 2016, 10:24 PM
Ola
Ola - avatar