Question: Here is the code, but there are some error: #include #include char matrix[3][3]; char check( void ); void init_matrix( void ); void player_move( void );

![char matrix[3][3]; char check(void); void init_matrix(void); void player_move(void); void computer_move(void); void disp_matrix(void);](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3b9f18f5e4_88066f3b9f0ed29a.jpg)
Here is the code, but there are some error:
#include#include char matrix[3][3]; char check(void); void init_matrix(void); void player_move(void); void computer_move(void); void disp_matrix(void); int main(void) { char done; char name; printf("**********************************************"); printf(" Tic Tac Toe "); printf("You will be playing aginest the computer "); printf("*********************************************** "); printf("What is your name "); scanf("%s" , &name); printf("Hello %s ...Let's have fun!!! You = X| Computer = 0 ", &name); done = ' '; init_matrix(); do { disp_matrix(); player_move(); done = check(); if(done!= ' ') break; computer_move(); done = check(); } while(done== ' '); if(done=='X') printf("You won! "); else printf("I won!!!! "); disp_matrix(); return 0; } void init_matrix(void) { int i, j; for(i=0; ifor(j=0; jvoid player_move(void) { int x, y; printf("Enter X,Y coordinates for your move: "); scanf("%d%d", &x, &y); x--; y--; if(matrix[x][y]!= ' '){ printf(" Invalid move, try again. "); player_move(); } else matrix[x][y] = 'X'; } void computer_move(void) { int i, j; for(i=0; ifor(j=0; jif(matrix[i][j]==' ') break; if(matrix[i][j]==' ') break; } if(i*j==9) { printf("draw "); exit(0); } else matrix[i][j] = 'O'; } void disp_matrix(void) { int t; for(t=0; tif(t!=2) printf(" ---|---|--- "); } printf(" "); } char check(void) { int i; for(i=0; iif(matrix[i][0]==matrix[i][1] && matrix[i][0]==matrix[i][2]) return matrix[i][0]; for(i=0; iif(matrix[0][i]==matrix[1][i] && matrix[0][i]==matrix[2][i]) return matrix[0][i]; if(matrix[0][0]==matrix[1][1] && matrix[1][1]==matrix[2][2]) return matrix[0][0]; if(matrix[0][2]==matrix[1][1] && matrix[1][1]==matrix[2][0]) return matrix[0][2]; return ' '; }
**********************************************************

Thanks
In this assignment, you will create a simple Tic Tac Toe game designed for one player (against the computer). You will need to create arrays and functions to complete this program. The first screen should ask the user for his name, print a welcome message, and displays an empty 3x3 Tic-Tac-Toe board. Then, the program should ask the user to put the coordinates of his move.* 1. comp2130@(none):/Documents/comp2130/c.lang File Edit View Search Terminal Help [comp2130@ (none) c_lang]$ ./game k*xkxxkxkkkkkkk**k* Tic Tac Toe You will be playing against the computer k*x**k**kxkxKKKKkkk*k** What is vour name? John Hello John Let's have fun !! ! You = X 1 Computer =0 Enter X,Y coordinates for your move: |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
