Question: Write a C++ program that plays a simple game of TicTacToe against a user. The user will input the Xs and the computer will counter

Write a C++ program that plays a simple game of TicTacToe against a user. The user will input the "X"s and the computer will counter with "O"s. The program will update the display after each user input and each computer input. The program will end after someone wins the game (all "X"s or all "O"s in a row) or all 9 spaces are played.

** Below is a screenshot of my main function. I already have this program 99% finished. I am just trying to add User Input Validation. I was thinking about changing my while loop to a do while loop possibly, somewhere between lines 39-41, or maybe using a "try" statement or For Loop? I just need some help tweaking this just a little. The Input Validation should display an error message if the user enters a value other than 0-8 to make a move on the Tic Tac Toe Display, and then re-prompt them to enter a number 0-8. It should say something like: "That Is Not A Valid Move. Please Enter A Number [0-8]. "

Write a C++ program that plays a simple game of TicTacToe against

domanip> E#include 10 11 #include #include #include using namespace std; 14 16 void Display(int]) 17 void compMove(int) 18 char Winner(intl); 19 20 int main) bool playGame true; const int spaces9; int num[spaces] = { -1, -1, -1, -1, -1, -1, .1, -1, -1 }; int x; int numMoves; char input; 24 25 28 while (playGame) 36 31 32 i++) for (int i a; i num[i-1: spaces; while (1) 34 35 36 37 38 39 Display (num) cout input; cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!