Tic-Tac-Toe Game
Write a program that allows two players to play a game of tic-tac-toe. Use a 2D char array with three rows and three columns as the game board. Each element of the 2D array should be initialized with a space. The program should work as follows.

1. When the program begins, each player should be prompted for his/her name (the names may contain spaces). Player 1 will be the Xs and player 2 will be the Os. After the players have entered their names, the initial game board should be displayed.
2. The program should run a loop that does the following until there’s a winner or a tie:
a. Allows player 1 to select a location on the board for an X.
b. Redisplays the game board to show player 1’s selection.
c. Determines if player 1 has won, or if there was a tie. If player 1 won, or if there was a tie, then the program should indicate it and end the game. If the game has not ended, then player 2 is allowed to select a location on the board for an O.
d. Redisplays the game board to show player 2’s selection.
e. Determines if player 2 has won, or if there was a tie. If player 2 won, or if there was a tie, then the program should indicate it and end the game.
3. Once a winner —if there was one—, or a tie —if nobody won— has been announced, the program should give the options of playing a new game or exiting the program. If a new game is selected, then the program should reset the game board and play another game.

Note: The name of the players should appear at the top of the screen —above the game board.

Note: A player selects a location on the board by specifying a row and column number. For example, to select the center of the board, the player would specify row 2 and column 2.

Player 1 wins when there are three Xs in a row, a column, or a diagonal on the game board. Similarly, Player 2 wins when there are three Os in a row, a column, or a diagonal on the game board. A tie occurs when all of the locations on the board are full, but there is no winner.

The program should display the name of the winner, if there is one.
Input Validation:

The program should check that numbers are entered for the row and column when the player selects a location on the board.

 The program should check that the location selected by the player is a valid unoccupied position on the board.
The program should continue to ask the player for a board location, until a valid one is provided.

You must divide the program into modules —functions— that perform the major tasks. The more functions the better. The main( ) function should basically consist of calls to other functions, and should be small and simple. A large amount of points will be deducted for having a large and complex main( ) function, and not enough functions.

Requirements:

 Your program MUST use constants whenever possible.
 Your program should follow the programming style guidelines discussed in class. In addition, it should be well documented and use descriptive variable names and function names. The name of a variable or function should reflect its purpose.
 Your program may NOT use global variables, unless they are constant global variables.
 Remember, reference parameters should only be used, if the original arguments have to be modified. Otherwise, you must use value parameters.
 Remember that a function argument and its corresponding parameter are two distinct variables, which occupy different storage locations in memory. To make sure, you don't confuse an argument with its corresponding parameter, I want you to name them differently. I WILL BE VERY STRICT ABOUT THIS AND WILL TAKE OFF LOTS OF POINTS!
 The description of the function, return value, and purpose of each of its parameters should be specified at the top of each function’s header.

I can have this done for you in a hour or so, but its gonna cost you $100.00 dollars, or $130.00 express.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.