Write a program that will allow two users to play tic-tac-toe. The program should ask for moves alternately from player X and player O. The program displays the game positions as follows:

1 2 3
4 5 6
7 8 9

The players enter their moves by entering the position numbers they wish to mark. After each move, the program displays the changed board. A sample board configuration is as follows:

X X O
4 5 6
O 8 9

IMPLEMENTATION:

Functions (mandatory):

void printboard (char tictactoe_board[]);

( displays the board layout)

void checkwinners(char tictactoe_board[], char& result);

(computes the winner if any, if 'X' is the winner result is X and if 'O' is winner, result set to 'O')

SAMPLE RUN:

1 2 3
4 5 6
7 8 9
Enter move:
2
1 X 3
4 5 6
7 8 9
Enter move:
5
1 X 3
4 O 6
7 8 9
Enter move:
8
1 X 3
4 O 6
7 X 9
Enter move:
9
1 X 3
4 O 6
7 X O
Enter move:
7
1 X 3
4 O 6
X X O
Enter move:
1
O X 3
4 O 6
X X O
Enter move:
4
O X 3
X O 6
X X O
Enter move:
5
That space is taken.
O X 3
X O 6
X X O
Enter move:
3
O X O
X O 6
X X O
Enter move:
2
That space is taken.
O X O
X O 6
X X O
Enter move:
6
O X O
X O X
X X O
Game over!
NO WINNERS!
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.