Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help with intro class review free write section Please write a count_unknow

ID: 675478 • Letter: N

Question

Need help with intro class review free write section

Please write a count_unknown_squares() that will traverse and count the number of UNKNOWN squares in an 0h h1 board, stored in a 2-dimensional array of proportions MAX_SIZE x MAX_SIZE.

const int MIN_SIZE = 2;
const int MAX_SIZE = 8;

const int UNKNOWN = 0;
const int RED = 1;
const int BLUE = 2;

const char UNKNOWN_LETTER = '-';
const char RED_LETTER = 'X';
const char BLUE_LETTER = 'O';

const string UNKNOWN_STRING = "unknown";
const string RED_STRING = "X";
const string BLUE_STRING = "O";

The size of the board is passed in as the size argument in every function you will write. The board is assumed to be square, so size is the size in both dimensions. size may be less than, but no more than, MAX_SIZE.

int count_unknown_squares(const int board[MAX_SIZE][MAX_SIZE], int size) {


    // your code here


    return 0;
}

Explanation / Answer

int count_unknown_squares(const int board[MAX_SIZE][MAX_SIZE], int size) {
    int count =0;
  
    for (int i=0; i<size; i++) {
        for (int j=0; j<size; j++) {
            if (board[i][j] == UNKNOWN) {
                count++;
            }
        }
    }
  
    return count;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote