Answers for "c++ pre increment vs post increment"

3

pre-increment vs post-increment

++x (pre-increment) means "increment the variable; the value of the expression is the final value"
x++ (post-increment) means "remember the original value, then increment the variable; the value of the expression is the original value"
Posted by: Guest on April-28-2020
0

pre increment vs post increment c++

b = x++;
// In this example suppose the value of variable ‘x’ is 5 then value of variable ‘b’ will be 5 because old value of ‘x’ is used.

b = ++y;
// In this example suppose the value of variable ‘y’ is 5 then value of variable ‘b’ will be 6 because the value of ‘y’ gets modified before using it in a expression.
Posted by: Guest on November-07-2021

Browse Popular Code Answers by Language