int x = 8; // Declare x as an integer and set it to 8
while (x < 10) // While x is less than 10 ..
{
x = x+1; //Add one to x
cout << x; //And then print x
}
It will loop over the stuff inside the { }, each time checking to see if x < 10 is still true. Once x is 10, it isn't anymore, and it'll move past it. So the first time, it'll add one, then print x. "9". 9 is less than 10, so it'll do it again. Add one, and print it. "10". 10 is not less than 10 so it doesn't do it again. Final output is "910"
int x=8;
while(x<10)
{
x=x+1//line 1
cout<<x;//Line 2
}
Above one using braces.
Because 'while' or 'if-else' or 'switch' or 'for' control structures execute only one line of code below to them ,if you dont use braces.
in your code the while(x<10) execute for only x=x+1;
cout<<x; is not part of while loop