Coders Packet

C++ code for tic tac toe game

By Harsh Kumar jha

This is a simple tic tac toe game written in c++ programming language. At the end of the game, it will also display the winner's name.

After compiling this c++ program, both users will be asked to enter their names respectively in the following manner : 

Welcome to Tic Tac Toe Game....!!
Player 1, Enter your name : XYZ

Player 2, Enter your name : ABC

After entering the name, the game board will be displayed on the screen. Now users will be asked to enter the box number between 1 to 9 of their choice. if the user enters any number between 1 to 9, their sign will be printed on that particular box number. If the user enters a number apart from 1 to 9 or a number that is already selected, "Box number is not available, try again" will be printed on the screen and the user will get another chance once again to choose his correct box number. If the user wins, his name will be printed on the screen in the following manner

 Congratulations , you won..!!

Or if the game draws "Oops Game draw. Better luck next time", will be printed on the screen.

Download Complete Code

Comments

No comments yet