Question: I need code for C++ program. Thanks Write a program that allows two players to play a game of tic-tac-toe. Use a two dimensional char

I need code for C++ program. Thanks

I need code for C++ program. Thanks Write a program that allows

Write a program that allows two players to play a game of tic-tac-toe. Use a two dimensional char array with 3 rows and 3 columns as the gameBoard. Each element in the array should be initialized with an asterisk (*). The program should run a loop that does the following logic (some small variations may work for you if it still keeps the tic-tac-toe game working) 1. Displays the contents of the board array. Do this in a function called displayBoard(gameBoard) 2. Asks player 1 to select a location on the board for an X by specifying a row and column number. Do this in a function called playerTurn(gameBoard, 'X') . IMPORTANT: you can not let the user choose a location that is already marked with an X or an O -- the playerTurn function must check for this and loop until the plaer has chosen an unused location 3. Display again the contents of the board again (displayBoard(gameBoard)) 4. Create a function gameOver(gameBoard) that determines if either player has won (either a complete row, column or diagonal in one symbol X or O). If someone has won declare the winner and exit the game. If all spaces are used (no more *) then declare it a tie and exit the game 5. Asks player 2 to select a location on the board for an O by specifying a row and columrn number. Do this in a funciton called playerTurn(gameBoard, 'O'). Then make a call to display the updated gameBoard by calling displayBoard(gameBoard) 6. Call again the function gameOver(gameBoard) .. LOOP--- If no winner and morespaces LOOP to #2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!