If you don't include any braces if/else statements only effect the statement directly below them. If you wanted it to just print welcome you would have to do.
In this case the x==8 returns true because x is 8
and it will do
cout << "welcome";
then the if are finish and it moves on to another statement which is
cout << "home";
The loop loops as long as x is smaller than 10. Each loop 1 is added to x. So, when x is 9, the computer checks: "Is x smaller than 10?" yes, it is, so the x = x + 1; statement runs once again, and x is made 10. At the next iteration, the expression x < 10 returns false because x is not longer smaller than 10, and so the program continues directly after the while loop, and that is at cout << x; Conclusion: the output will be 10.
x is 8.
Check to see if x is less than 10.
It is, because 8 is less than 10, so carry on.
Add one to x (so x is now 9).
Loop is finished. Go back to the check.
x is 9.
Check to see if x is less than 10.
It is, because 9 is less than 10, so carry on.
Add one to x (so x is now 10).
Loop is finished. Go back to the check.
Check to see if x is less than 10.
It is NOT, because 10 is not less than 10. So no more looping.