I think you have a conceptual misunderstanding - statements are executed in order once unless they are in a looping structure. Your if-else is not in a looping structure, so it is run once and never again. Because of this, x never changes to 10 and your while loop never runs either.
Also, x = x++; does not do what you think it does, in fact it does nothing at all. Just write ++x; by itself.
And for future reference, surround your code with code tags:
1 2 3 4 5 6
std::cout << "Syntax highlighting makes code easier to read" << std::endl;