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

I need help finishing my program for C++. The program I had to makewas a tic-tac

ID: 3611897 • Letter: I

Question

I need help finishing my program for C++. The program I had to makewas a tic-tac-toe game. The code I have written displays the board(not the actual board, it is set up using numbers) and I have itrun through the entire board without a winner to verify that itworks. Now I have to make it so it recognizes when there is awinner. Here is my code:

#include <iostream>

using namespace std;

void showBoard(char board[]);

void showBoard(char board[])
{
    cout << endl;
    for (int i=0; i<9;i++)
    {
        cout << board[i]<< " ";
        if (((i+1) % 3) == 0) cout<< endl;
    }
    cout << endl;
}


int main()
{
char board[9];       
int i;
int numMoves = 0;       
char whoseTurn = 'X';   
int move;

cout << "Player X starts. ";

for (i=0; i<9; i++)
{
    board[i] = '1' + i;
}


while (numMoves < 9)
{
    showBoard(board);
    cout << "Enter move: " <<endl;
    cin >> move;
    if ((move <1) || (move>9))
    {
        cout << "Invalidmove, try again." << endl;
    }
    else
    {
        move--;
        if ((board[move]=='X')|| (board[move]=='O'))
        {
            cout << "That space is taken. " << endl;
        }
        else
        {
            board[move] = whoseTurn;
            if(whoseTurn == 'X')
                 whoseTurn = 'O';
            else
               whoseTurn = 'X';
            numMoves++;
        }
    }
}
showBoard(board);
cout << endl << "Game over!" << endl;

system("pause");
return 0;
}

Any help with this would be much appreciated. The sooner thebetter.

Explanation / Answer

please rate - thanks try this   - changes in red-I think Igot them all #include using namespace std; void showBoard(char board[]); bool checkForWinner(char board[]); void showBoard(char board[]) {     cout
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