Question
This is one whole C program for a tic tac toe game. I have included questions in the pictures and in the text too. So,
This is one whole C program for a tic tac toe game. I have included questions in the pictures and in the text too. So, if you don't understand what's written in pictures you can look at the text. Also, make sure everything is the same as the output pictures. Thank you
Purpose The purpose of this assignment is to help you to practice working with functions, arrays, and design simple algorithms Learning Outcomes Develop skills with multidimensional arrays Learn how to traverse multidimensional arrays Passing arrays to functions Develop algorithm design skills (e.g. recursion) Problem Overview Problem Overview Tic-Tac-Toe (also known as noughts and crosses or Xs and Os) is a paper-and-pencil game for two players, X and O, who take turns marking the spaces in a 33 grid. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row wins the game. Questions 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])[0 Points] Here is sample output showing the board after initializing it using the function
void InitializeBoard(int m, int n , char board[][n]){ int c =1; for(int i =0; i University of Windsor COMP1410 - Winter 2020 School of Computer Science 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]). [10 points] 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]). [10 points] Here is a sample output when we execute the function CreateBoard 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. Here is an example of this behaviour. University of Windsor COMP1410 - Winter 2020 School of Computer Science 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]). [10 points] University of Windsor COMP1410 - Winter 2020 School of Computer Science 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])[30 points] Q6) Write a C function that finds which player (player X or O) has won the game (if any) use recursion to implement this function. If there is no winner the function should return 'D' otherwise return the winner symbol, either 'X' or 'O' The function prototype is char WhoIsTheWinner(int m, int n, char board[][n])[30 points] Q7) Write a main function that displays a menu for the user and asks him to select which the function he/she wants to
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started