Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1) Write a C function that allows the user to initialize a Tic-Tac-Toe board. The board is a 2D array of size 3x3. The function

Q1) Write a C function that allows the user to initialize a Tic-Tac-Toe board. The board is a 2D array of size 3x3. The function will set an id for each cell of the board starting from 1 and stop at 9. The function prototype is void InitializeBoard(int m, int n , char board[][n])

void InitializeBoard(int m, int n , char board[][n]){

int c =1;

for(int i =0; i

for(int j=0; j< n; j++){

board[i][j] = c+'0';

c++;

}

}

}

NOTE: The answer for Q1 is given to you as a help to get you start

Q2) Write a C function that allows the user to print a Tic-Tac-Toe board. The function prototype is void PrintBoard(int m, int n, char board[][n]).

Q3) Write a C function that allows the user to create a Tic-Tac-Toe board. In this case, the board is a 2D array of size 3x3, The function allows the user to create a board and set some X or O on the board at any cell. The function prototype is void CreateBoard(int m, int n, char board[][n]).

If the user typed any invalid input like cell number 21 or rather than entering X or O the user typed C the function should ignore his input and ask him to enter a valid input.

Q4) Write a C function that allows the user to check if a given Tic-Tac-Toe board is a valid board or an invalid board. The board is valid if it is an empty board or if the difference between the total number of X and the total number of O symbols on the board is 0 or 1.

The function prototype is int IsValidBoard(int m, int n, char board[][n]).

Q5) Write a C function that allows the user to find if any next move or next play for any player X or O who has the turn to play is winning move. The function will print the cell number or ID that if the player places an X or O in it he/she will win the game. If there is more than one cell where the player could place his symbol in and win the game the function should print all the winning cells for that player. The function prototype is void ListWinningCells(int m, int n, char board[][n])

Q6) Write a main function that displays a menu for the user and asks him to select which function he/she wants to test.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

Students also viewed these Databases questions

Question

How many multiples of 4 are there between 10 and 250?

Answered: 1 week ago

Question

How many three-digit numbers are divisible by 7?

Answered: 1 week ago

Question

8. Do the organizations fringe benefits reflect diversity?

Answered: 1 week ago