Question: How do I create a c++ code for... Please help. Write a program that allows two players to play a game of tic-tac-toe. Use a
How do I create a c++ code for...


Please help.
Write a program that allows two players to play a game of tic-tac-toe. Use a two-dimensional char array with three rows and three columns as the game board. Each element in the array should be initialized with an asterisk (*). The program should run a loop that: Displays the contents of the board array 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 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 Determines whether a player has won, or 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. At game end, show the menu to Play the Game Display the Game Stats, or Quit. Player 1 wins when there are three Xs in a row on the game board. The Xs can appear in a row in a column, or diagonally across the board. Player 2 wins with the same conditions. A tie occurs when all of the locations on the board are full, but there is no winner The user is allowed to play the game multiple times. Use a menu to allow the player to choose to Play the Game, Display the Game Stats, or Quit. The screen clears each time the user plays a new game Track game stats as follows- total number of games played, how many times Player 1 wins, how many times Player 2 wins, and how many tie games Use these functions as guidelines. Other designs are acceptable as long as the program is complete, logical and accurate and utilizes a 2D array, structs, functions, parameters and good design. Outside of main define a struct Player with attributes name, symbol (X or O), wins losses, ties Inside main - TTT is a 2 player game. Either create 2 Player variables or an array of Players with 2 elements. Pass the structs as parameters when needed Prompt the user to input two names for the players. Randomly decide who goes first and assign that name to Player 1. Randomly assign X or O to the players o o main - Show a menu with 3 options - Play Game, Show Stats, and Quit. Play game - Loop to display the board, allow player 1 to take a turn, check for a win or tie, allow player 2 to take a turn (if not a win or tie), display the board, if not a win or tie then loop again. Once a win or tie has been determined, display the game board one last time and display a message about the winner. Show the menu o
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
