Write a program that plays a tic-tac-toe game.

Assignment Help C/C++ Programming
Reference no: EM13159228

Using functional decomposition, write a program that plays a tic-tac-toe game. Ask the user if they want to go first; the player (user or computer) that goes first is designated X and the other player is O. The board is represented by three one-dimensional arrays (a, b, and c) each with three members (0, 1, 2). The players take turns making moves by designating a letter and a number; e.g., a1. Each player's move must be evaluated to make sure it is valid (within the range and not already occupied). If the user makes a bad move, tell them and ask for another move. If the computer makes an invalid move, keep getting a move until one is valid

In this game, the computer is not intelligent; its moves are random.

A player wins if they occupy three positions in a row; e.g., a1, b1, and c1, or a0, a1, and a2, etc.. Don't forget diagonals.

Before the game starts and after each valid move, show the user the board. Use a combination of spaces, dashes, and vertical lines.

The game ends when a player wins or the maximum number of moves has occurred. If the maximum number of moves takes place and there is no winner, the game is a tie. Tell the user what the result is (winner or tie).

When the game is over, ask the player if they want to play again. If yes, clear the board and start again; if no, say good bye and exit.

Use functions as appropriate.

 

 

Reference no: EM13159228

Questions Cloud

How did this likely affect labours share in national income : Does an increase in the average annual labour income imply that the individual worker's labour income has increased and
How does the hiv virus make new viral proteins : How does the HIV virus make new viral proteins and viral genomes, Which of these processes are carried out by viral vs. human enzymes/structures? How does the virus get out again or be totally eliminated from the body? Remember to focus on the flo..
Family-status of children-role of women : Research what a person would need to know in order to visit your country successfully. In your search, look for topics such as family, status of children, role of women, role of the aged, customs,
Fair-value of identifiable net assets : In a business combination accounted for as an acquisition, how should the excess of fair value of identifiable net assets acquired over implied value be treated?
Write a program that plays a tic-tac-toe game. : Using functional decomposition, write a program that plays a tic-tac-toe game.
Correct example of inheritance : Which of the following relationships is not a correct example of inheritance?  Parent to Children  Aunt to Uncle  Grandparent to Grandchild
What is a marketing information system : What is a marketing information system and what should it provide? How is the value of a marketing information system measured?
What is the change in the number of unemployed people : What is the change in the number of unemployed people in this particular month and what is the change in the number of  employed people  in the same period?
Competitive intelligence activities : What competitive intelligence activities can technology help a company to perform better? Are there limitations? Which ones will you choose for which industries? Explain

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write function compute square root together with prototype

Write a C++ function called compute together with its prototype that is passed 2 integers, A and B and returns the square root of A2+B2 ,as a double.

  Write c program to accept inputs from user

Write down simple c program which accepts following inputs from user that is username and password, it must ask user what he will like to learn today and also ask user to enter char m=math , e= English.

  Write a program that will be used to gather statistical data

Write a program that will be used to gather statistical data about the number of movies

  Show the deatils of an emplyoee - c programming

Show the deatils of an emplyoee in a neat format.

  Create a text adventure game that uses pointers

Create a text adventure game that uses pointers. You have a rich, eccentric Uncle Billy who is soon to be deceased.

  Model-view-controller

Explain Model-View-Controller paradigm

  Main function to input twenty integers in given range

Write a main function to input 20 integers in range of 1-6, function should count number of times the numbers 2 and 5 occur. function must declare statics variables count2 and count5.

  Draws a single level for a "rogue­like" computer game

You will write a program that draws a single level for a "Rogue­like" computer game. The program will parse a line of input text from an input file (room.txt), use the parsed text to determine the shape of the room and its contents and then draw the ..

  Using opengl to create a cube

Write a program in C/C++ using OpenGL to create (without using built in function) a cube by implementing translation algorithm by translating along 1. X-axis, 2.Y-axis and 3. X and Y plane

  Object-oriented systems is the concept of object

At the heart of all object-oriented systems is the concept of an object. Simply stated, an object is a set of related characteristics and their associated actions.

  Pros and cons of choosing two servers

Classify the two alternatives in terms of what type of application architecture they use. b. Outline the pros and cons of the two alternatives and make a recommendation to Fred about which is better.

  Write program which prompts user to enter numbers

Write down the program which prompts the user to enter numbers, findsout how many positive and negative values have been entered, and calculates sum and average of numbers entered.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd