When starting out, it helps to always use braces for compound statements. Your loop should look like this:
while ( x < y ) {
x = x + 1;
cout<< x <<'\n';
}
If you don't have the braces, only the first statement will be the whole of the loop body. So in your code, the loop is translated like this:
while ( x < y ) {
x = x + 1;
}