In C language, Write a function win with the following prototype int win(char bo
ID: 3729515 • Letter: I
Question
In C language,
Write a function win with the following prototype int win(char board[6][6], char player) The function win should return a 1 if the character player is found in three consecutive positions in the board. Consecutive for this lab means in the same row, or in the same column, NOT on a diagonal For the board shown below, A B G G E B A G G G 7 The following values should be returned by win0 if called as win(board A) would return O win(board,B) would return 0 win(board,D) would return 0 win(board'G) would return 1 win(board,O) would return 0 win(board,X) would return 0 win(board,Z) would return 1 5 points will be for the autograded tests, the remaining 5 points will be for a header with your name (1 point), appropriate style (2 points) and appropriate comments (2 points)Explanation / Answer
int win(char board[6][6], char player) {
int i, j;
for(i = 0; i <= 3; ++i) {
for(j = 0; j <= 3; ++j) {
if(board[i][j] == ch && board[i+1][j] == ch && board[i+2][j] == ch) {
return 1;
}
if(board[i][j] == ch && board[i][j+1] == ch && board[i][j+2] == ch) {
return 1;
}
}
}
return 0;
}