++ -- expressions

int x = 5;
for (int j = 0; j < 10; j++) {
x++;
}
cout << x << endl;
a. 5 b. 9
c. 15 d. 16

I'm still confused on how to go about this....
i know the answer is 15 but can someone please explain step by step why?
thanks
x++ is equals to x = x + 1
closed account (E3h7X9L8)
the for statement will increment x by 1 (x++) till j which is initialized as 0 will reach the value 10 , that means at the end of for loop x will have the value 15
Topic archived. No new replies allowed.