Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedPurpose 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

Purpose The purpose of this assignment is to help you to practice working with functions, arrays, and design simple algorithms 02) Write a c function that allows the user to print a Tic-Tac-Toe board. The function prototype is void PrintBoard(int n, int n, char board[ ][n]). [10 points] 0 2 X Learnine Outcomes Develop skills with multidimensional arrays Learn how to traverse multidimensional arrays Passing arrays to functions Develop algorithe design skills (e.g. recursion) 406 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 01) Write a c function that allows the user to initialize a Tic-Tac-Toe board. The board is a 2D array of size 33. The function will set an id for cach cell of the board starting from 1 and stop at 9. The function prototype is void InitializeBoard(int , int n, char board[[n])[ Points] Here is sample output showing the board after initializing it using the function 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 oro on the board at any cell. The function prototype is void CreateBoard(int , int n, char board[][]). [10 points) Here is a sample output when we execute the function Create aard Enter the number of the cell where you want to insert Xor or enter 1 to exit Program F ored with code Type X or o void InitializeBoard(int , int n, char board[][]) { int c=1; for(int i =; i<>

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

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

Students also viewed these Databases questions

Question

Refer to Example 10.18 and find a 90% confidence interval for /0.

Answered: 1 week ago

Question

Choose an appropriate organizational pattern for your speech

Answered: 1 week ago

Question

Writing a Strong Conclusion

Answered: 1 week ago