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

Write a C program can display a grid and take input from user. Start program by:

ID: 3868311 • Letter: W

Question

Write a C program can display a grid and take input from user.

Start program by: game playera playerb height width. (Board size 1-1000)

0 wins by connecting left to right edges while x wins by connecting top and bottom edges

When winner is determined, display player? wins

Display error messages:

When user input incorrect player type        message: invalid type

When grid dimmesion is invlaid            message: invalid grid

f this isax ridd Player A: 00 0 Player B: 11 Player A wins: 0 0 Player B wins

Explanation / Answer

#include <iostream>

#include <stdlib.h>

#include <time.h>

#include <iomanip>

using namespace std;

char **createboard(int rows, int cols)

{

char** boardArray = new char*[rows];

for (int i = 0; i < rows; ++i) {

boardArray[i] = new char[cols];

}

for (int i = 0; i < rows; ++i) {

for (int j = 0; j < cols; ++j) {

boardArray[i][j] = char(i + 65);

}

}

for (int i = 0; i < rows; ++i) {

for (int j = 0; j < cols; ++j) {

cout << boardArray[i][j];

}

cout << endl;

}

for (int i = 0; i < rows; ++i) {

delete[] boardArray[i];

}

delete[] boardArray;

return boardArray;

}

int main()

{

int rows = 0;

int cols = 0;

char **boardArray = createboard(rows, cols);

cout << " Welcome to Tic Tac Toe v1! " << endl;

cout << " Choose your board width: " << endl;

cin >> rows;

cout << " Choose your board height " << endl;

cin >> cols;

cout << endl;

createboard(rows, cols);

system("pause");

}

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