Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that allows two players to play a game of tic-tac-toe. Use a two

ID: 3658702 • Letter: W

Question

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) Displays the contents of the board array. Do this in a function called displayBoard(gameBoard) 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 Display again the contents of the board again (displayBoard(gameBoard)) 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. Asks player 2 to select a location on the board for an O by specifying a row and column number. Do this in a funciton called playerTurn(gameBoard, 'O'). Then make a call to display the updated gameBoard by calling displayBoard(gameBoard) Call again the function gameOver(gameBoard) .. LOOP--- If no winner and more * spaces LOOP to #2

Explanation / Answer

#include #include char square[10] = {'o','1','2','3','4','5','6','7','8','9'}; int checkwin(); void board(); int main() { int player = 1,i,choice; char mark; clrscr(); do { board(); player=(player%2)?1:2; cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote