- Return type integer - Parameter list i. 1-d character array (i.e. move), size 3 ii. 2-d character array (i.e. board), size 8 rows and 8 cols - Declare local variable open, data type integer, initialized to FALSE - Declare local variable rowInt, data type integer, set equal to function call getMoveRow, passing parameter move as an argument - Declare local variable colInt, data type integer, set equal to function call getMoveCol, passing parameter move as an argument - Set local variable open equal to TRUE or FALSE based on logic i. If the rowInt is not INVALID and ii. If the colInt is not INVALID and iii. If the element in array board at the row/col location is equal to a SPACE, then the square is open iv. Otherwise, it is not open - Return variable open This code needs to be updated using the above instructions(I have tried updating the code using the instructions, but there may be some errors in the code. Please fix and update the code): int isOpen(char move[THREE], char board[ROW][COL]) { int open = FALSE; int rowInt = getMoveRow(move); int colInt = getMoveCol(move); if(rowInt != INVALID && colInt != INVALID && board[rowInt][colInt] == SPACE) { open = TRUE; } else open = FALSE; return open; }
I need help writing function isOpen to do the following in C Programming
- Return type integer
- Parameter list
i. 1-d character array (i.e. move), size 3
ii. 2-d character array (i.e. board), size 8 rows and 8 cols
- Declare local variable open, data type integer, initialized to
FALSE
- Declare local variable rowInt, data type integer, set equal to
function call getMoveRow, passing parameter move as an argument
- Declare local variable colInt, data type integer, set equal to
function call getMoveCol, passing parameter move as an
argument
- Set local variable open equal to TRUE or FALSE based on logic
i. If the rowInt is not INVALID and
ii. If the colInt is not INVALID and
iii. If the element in array board at the row/col location is
equal to a SPACE, then the square is open
iv. Otherwise, it is not open
- Return variable open
This code needs to be updated using the above instructions(I have tried updating the code using the instructions, but there may be some errors in the code. Please fix and update the code):
int isOpen(char move[THREE], char board[ROW][COL])
{
int open = FALSE;
int rowInt = getMoveRow(move);
int colInt = getMoveCol(move);
if(rowInt != INVALID && colInt != INVALID && board[rowInt][colInt] == SPACE)
{
open = TRUE;
}
else
open = FALSE;
return open;
}
I would rate the work if my question is answered!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps