Question: I wrote this small c++ program to implement tic-tac-toe. However, I run into a small problem that prevents me from terminating the game when it is over.

```
int main(){
    bool a= true;
    while (a){
        int x,y,x1,y1;
        std::cout<<"player 1 move"<<'\n';
        std::cin>>y>>x;
        player1(x,y);
        printboard();
        if (game_finished()){
            std::cout<<"player 1 won"<<'\n';
            a = false;
            }
        std::cout<<"player 2 move"<<'\n';
        std::cin>>y1>>x1;
        player2(x1,y1);
        printboard();
        if (game_finished()){
            std::cout<<"player 2 won"<<'\n';
            a = false;
        }
    }

```

so what is happening is that, for example, when player 1 has won the game, the program will still ask player 2 to make another move before it terminates the while loop. The solution seems to be simple but I just cant think of it at this moment. Any input is appreciated.

Answer: 
The `break` statement will exit a loop.
You can use a `break` statement.

That said, they are usually discouraged because it makes more difficult understanding the code later. I would stick with putting the second move loigc in an `else` branch.