Write a C program to implement a TIC TAC TOE game.This program is a small game Tic Tac Toe in C programming.
Here two users can play this game and after completing the game program will show the winner user name. This program is created using by Two Dimensional Array
Below is the source code of the C program to implement a TIC TAC TOE game which is successfully compiled and run on the windows system.The Output of the program is shown below.
SOURCE CODE : :
OUTPUT : :
TIC TAC TOE *********** 1.Start The Game 2.Quit The Game Enter your choice(1-2) : 1 Enter the name of the player playing for 'X': John Smith Enter the name of the player playing for 'O': Steve TIC TAC TOE BOARD ***************** 1 2 3 _____________________________ ? ? ? ? 1 ? ? ? ? _____________________________ ? ? ? ? 2 ? ? ? ? _____________________________ ? ? ? ? 3 ? ? ? ? ------------------------------ TURN FOR John Smith: Enter the row no. : 2 Enter the column no. : 2 TIC TAC TOE BOARD ***************** 1 2 3 _____________________________ ? ? ? ? 1 ? ? ? ? _____________________________ ? ? ? ? 2 X ? ? ? ? _____________________________ ? ? ? ? 3 ? ? ? ? ------------------------------ TURN FOR Steve: Enter the row no. : 3 Enter the column no. : 3 TIC TAC TOE BOARD ***************** 1 2 3 _____________________________ ? ? ? ? 1 ? ? ? ? _____________________________ ? ? ? ? 2 X ? ? ? ? _____________________________ ? ? ? ? 3 O ? ? ? ? ------------------------------ TURN FOR John Smith: Enter the row no. : 1 Enter the column no. : 3 TIC TAC TOE BOARD ***************** 1 2 3 _____________________________ ? ? ? ? 1 X ? ? ? ? _____________________________ ? ? ? ? 2 X ? ? ? ? _____________________________ ? ? ? ? 3 O ? ? ? ? ------------------------------ TURN FOR Steve: Enter the row no. : 3 Enter the column no. : 1 TIC TAC TOE BOARD ***************** 1 2 3 _____________________________ ? ? ? ? 1 X ? ? ? ? _____________________________ ? ? ? ? 2 X ? ? ? ? _____________________________ ? ? ? ? 3 O O ? ? ? ? ------------------------------ TURN FOR John Smith: Enter the row no. : 3 Enter the column no. : 2 TIC TAC TOE BOARD ***************** 1 2 3 _____________________________ ? ? ? ? 1 X ? ? ? ? _____________________________ ? ? ? ? 2 X ? ? ? ? _____________________________ ? ? ? ? 3 O X O ? ? ? ? ------------------------------ TURN FOR Steve: Enter the row no. : 1 Enter the column no. : 2 TIC TAC TOE BOARD ***************** 1 2 3 _____________________________ ? ? ? ? 1 O X ? ? ? ? _____________________________ ? ? ? ? 2 X ? ? ? ? _____________________________ ? ? ? ? 3 O X O ? ? ? ? ------------------------------ TURN FOR John Smith: Enter the row no. : 2 Enter the column no. : 1 TIC TAC TOE BOARD ***************** 1 2 3 _____________________________ ? ? ? ? 1 O X ? ? ? ? _____________________________ ? ? ? ? 2 X X ? ? ? ? _____________________________ ? ? ? ? 3 O X O ? ? ? ? ------------------------------ TURN FOR Steve: Enter the row no. : 2 Enter the column no. : 3 TIC TAC TOE BOARD ***************** 1 2 3 _____________________________ ? ? ? ? 1 O X ? ? ? ? _____________________________ ? ? ? ? 2 X X O ? ? ? ? _____________________________ ? ? ? ? 3 O X O ? ? ? ? ------------------------------ TURN FOR John Smith: Enter the row no. : 1 Enter the column no. : 1 TIC TAC TOE BOARD ***************** 1 2 3 _____________________________ ? ? ? ? 1 X O X ? ? ? ? _____________________________ ? ? ? ? 2 X X O ? ? ? ? _____________________________ ? ? ? ? 3 O X O ? ? ? ? ------------------------------ MATCH DRAWS Press any key.... TIC TAC TOE BOARD ***************** 1 2 3 _____________________________ ? ? ? ? 1 X O X ? ? ? ? _____________________________ ? ? ? ? 2 X X O ? ? ? ? _____________________________ ? ? ? ? 3 O X O ? ? ? ? ------------------------------ MATCH DRAWS!! Press any key....... Want To Play(Y/N) ? nneed an explanation for this answer? contact us directly to get an explanation for this answer