Question: Design a program in C++ that allows two players to play a game of tic-tac-toe. Use a two-dimensional String array with three rows and three

Design a program in C++ that allows two players to play a game of tic-tac-toe.  Use a two-dimensional String array with three rows and three columns as the game board.  Each element of the array should be initialized with an asterisk (*).  The program should run a loop that does the following:

1. Display the contents of the board array.

2. Allows player 1 to select a location on the board for an X.  The program should ask the user to enter the row and column number. 

3. Allows player 2 to select a location on the board for an O.  The program should ask the user to enter the row and column number.

4. Determines whether a player has won or if a tie has occurred.  If a player has won, the program should declare that player the winner and end.  If a tie has occurred, the program should say so and end.   

5. Player 1 wins when there are three X's in a row on the game board.  Player 2 wins when there are three O's in a row on the game board.   The winning X's or O's can appear in a row, in a column, or diagonally across the board.  A tie occurs when all of the locations on the board are full, but there is no winner.  

Step by Step Solution

3.47 Rating (150 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The answer provided below has been developed in a clear step by step mannerStep 1 board 1 I turn whi... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!