Skip to content

This repository contains a simple implementation of the classic Tic Tac Toe game in the C programming language. The game is played on the command line interface, and users can take turns placing X's and O's on the 3x3 board until someone wins or the game ends in a tie. Enjoy!

Notifications You must be signed in to change notification settings

abhixsh/Tic-Tac-Toe-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tic Tac Toe Game in C

This is a simple Tic Tac Toe game implemented in C programming language. The game is played between a human player and a computer. The board is represented using a 2D array of characters. The player uses the X symbol while the computer uses the O symbol. The game ends when either the player or the computer has three symbols in a row or when the board is full. The winner is determined by checking the rows, columns, and diagonals of the board.

Features:

  • Simple command-line interface
  • Randomized computer moves
  • Checks for invalid moves by the player
  • Determines the winner and prints the outcome of the game

How to Use

  1. Clone the repository or download the number_guessing_game.c file.
  2. Compile the program using a C compiler.
  3. Run the compiled program in the terminal or command prompt.
  4. Follow the prompts to play the game

Functionality:

  • The resetBoard() function initializes the 2D array to empty spaces.
  • The printBoard() function prints the current state of the board.
  • The checkFreeSpaces() function returns the number of empty spaces on the board.
  • The playerMove() function allows the player to enter their move by selecting a row and column on the board. It checks for invalid moves and prompts the player to enter a valid move.
  • The computerMove() function generates random moves for the computer as long as there are still empty spaces on the board.
  • The checkWinner() function checks for a winner by checking the rows, columns, and diagonals of the board. If a winner is found, it returns the symbol of the winner. If there is no winner, it returns an empty space.
  • The printWinner() function prints the outcome of the game based on the winner.

Game Output Screenshots

01.jpg 02.jpg

About

This repository contains a simple implementation of the classic Tic Tac Toe game in the C programming language. The game is played on the command line interface, and users can take turns placing X's and O's on the 3x3 board until someone wins or the game ends in a tie. Enjoy!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages