Answered step by step
Verified Expert Solution
Question
1 Approved Answer
this is the current code i have for C + + to make a tic tac toe game but when I try to execute it
this is the current code i have for C to make a tic tac toe game but when I try to execute it it doesn't leave an X or a O in the slots the player picks and i need some help?
#include
#include
#include
#define SIZE
#define EMPTY
void initializeBoardint boardSIZESIZE
int num ;
for int i ; i SIZE; i
for int j ; j SIZE; j
boardij num;
void printBoardint boardSIZESIZE
printf
;
for int i ; i SIZE; i
for int j ; j SIZE; j
if boardijEMPTY
printf;
else
printfd boardij;
if j SIZE printf;
printf
;
if i SIZE printf
;
printf
;
int checkWinint boardSIZESIZE
for int i ; i SIZE; i
if boardi boardi && boardi boardi return boardi;
if boardi boardi && boardi boardi return boardi;
if board board && board board return board;
if board board && board board return board;
return EMPTY;
int checkTieint boardSIZESIZE
for int i ; i SIZE; i
for int j ; j SIZE; j
if boardij EMPTY return ;
return ;
int main
int boardSIZESIZE;
int currentPlayer, choice, row, col, winner, playAgain;
char symbolsXO;
srandtimeNULL;
do
initializeBoardboard;
currentPlayer rand;
winner EMPTY;
while
printBoardboard;
printfPlayer c enter your choice: symbolscurrentPlayer;
scanfd &choice;
if choice choice
printfInvalid choice! Please choose a number between and
;
continue;
row choice SIZE;
col choice SIZE;
if boardrowcol EMPTY
printfInvalid choice! Please choose an empty cell.
;
continue;
boardrowcol EMPTY;
ifwinner checkWinboard EMPTY
printBoardboard;
printfPlater c wins!
symbolswinner;
break;
currentPlayer currentPlayer;
printfDo you want to play again? for yes, for No: ;
scanfd &playAgain;
while playAgain;
return ;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started