You are on page 1of 16

`Project-I Report 

 
on 

Tic Tac Toe


submitted towards the partial fulfillment of  
the requirement for the award of the degree of 

Bachelor of Technology 
in 
Information Technology 

Submitted by 
Aryan Rajput 
2K20/B10/08 

Under the Supervision 


of
Mr. Prashant Giridhar
Shambharkar

Department of Information Tech. 


Delhi Technological University  Bawana Road. Delhi

DELHI TECHNOLOGICAL UNIVERSITY


(FORMERLY Delhi College of Engineering)

Bawana Road, Delhi-110042

CANDIDATE’S DECLERATION
We, (Aryan Rajput(2k20/b10/08) )students of B. Tech.
(Information Technology) hereby declare that the project
Dissertation titled ”Tic Tac Toe” which is submitted by us to the
Department of Information Tech, Delhi Technological
University, Delhi in partial fulfilment of the requirement for the
award of the degree of Bachelor of Technology, is original and
not copied from any source without proper citation. This work
has not previously formed the basis for the award of any
Degree, Diploma Associateship, Fellowship or other similar title
or recognition.

Place: Delhi Aryan Rajput (2k20/b10/08)

Date:
INFORMATION TECHNOLOGY
DELHI TECHNOLOGICAL UNIVERSITY

(FORMERLY Delhi College of Engineering)

Bawana Road, Delhi-110042

CERTIFICATE
I hereby certify that the project Dissertation titled ”Tic Tac Toe“
which is submitted by Aryan Rajput(2k20/b10/08) Delhi
Technological University, Delhi in complete fulfilment of the
requirement for the award of the degree of the Bachelor of
Technology, is a record of the project work carried out by the
students under my supervision. To the best of my knowledge
this work has not been submitted in part or full for any Degree
or Diploma to this University or elsewhere.

Place: Delhi Mr. Prashant Gridhar Shambharkar

Date: (SUPERVISOR)
INFORMATION TECHNOLOGY
DELHI TECHNOLOGICAL UNIVERSITY
(FORMERLY Delhi College of Engineering)

Bawana Road, Delhi-110042

ABSTRACT
This report is an introduction to the Tic Tac Toe
game in C programming. Anybody, who doesn’t
know even the basics of Tic Tac Toe in C ,will be
certainly able to understand and gain the great
knowledge from this report. The core theme of the
report focuses on the development of Tic Tac Toe
game in C language. The report also contains the
strategy of making Tic Tac Toe game which serve a
good idea to make a Tic Tac Toe game program in
C language to the programmer . The most of the
idea of making this game and report is taken from “
Let Us C - by Yashwant Kanetkar’’ , Schaum’s
Outline-C(TMH publications), and Internet
(Wikipedia ,Google etc.)
INFORMATION TECHNOLOGY
DELHI TECHNOLOGICAL UNIVERSITY

(FORMERLY Delhi College of Engineering)

Bawana Road, Delhi-110042

ACKNOWLEDGEMENT
In performing our major project, we had to take the help and
guideline of some respected persons, who deserve our greatest
gratitude. The completion of this assignment gives us much
pleasure. We would like to show our gratitude Dr Mentor for
major project. Giving us a good guideline for report throughout
numerous consultations. We would also like to extend our
deepest gratitude to all those who have directly and indirectly
guided us in writing this assignment. Many people have made
valuable comment suggestions on this proposal which gave us
an inspiration to improve our assignment. We thank all the
people for their help directly and indirectly to complete our
assignment. In addition, we would like to thank Department of
Information Technology, Delhi Technological University for
giving us the opportunity to work on this topic.
Contents
ABSTRACT
ACKNOWLEDGEMENT
Introduction
Hardware and Software used
Important Things Used
 Board()
 Checkwin()
 Square Character array
 Do while loop

CONCLUSION
REFERENCES
INTRODUCTION
Tic-tac-toe is not a very challenging game for
human beings. If you’re an enthusiast, you’ve
probably moved from the basic game to some
variant like three dimensional tic-tac-toe on a
larger grid. If you sit down right now to play
ordinary three-by-three tic-tac-toe with a friend,
what will probably happen is that every game
will come out a tie. Both you and your friend
can probably play perfectly, never making a
mistake that would allow your opponent to win.
But can you describe how you know where to
move each turn? Most of the time, you probably
aren’t even aware of alternative possibilities;
you just look at the board and instantly know
where you want to move. That kind of instant
knowledge is great for human beings, because
it makes you a fast player. But it isn’t much help
in writing a computer program. For that, you
have to know very explicitly what your strategy
is.
Hardware AND
Software Used
Microsoft visual studio code IDE
Windows 10 (64 bit)
Processor-Amd Ryzen 4600HS
Ram-8 gb
C programming language
IMPORTANT
THINGS USED
There are two important functions used in
this project:-
Board()
This function is used to draw tic tac toe
board on console and show player’s mark
i.e (X or O) and empty places with
numbers on them like this
Board Function Body
void board()
{
system("cls");
printf("\n\n\tTic Tac Toe\n\n");

printf("Player 1 (X) - Player 2 (O)\n\n\n");

printf(" | | \n");
printf(" %c | %c | %c \n", square[1], square[2],
square[3]);

printf("_____|_____|_____\n");
printf(" | | \n");

printf(" %c | %c | %c \n", square[4], square[5],


square[6]);

printf("_____|_____|_____\n");
printf(" | | \n");

printf(" %c | %c | %c \n", square[7], square[8],


square[9]);

printf(" | | \n\n");
}
CHECKWIN()
This function returns the game status i.e
whether the game of tic tac toe is in
progress(returns -1) or the game is finished
with a player’s win(returns 1)

(else) the game is draw.


Checkwin Function Body

int checkwin()
{
if (square[1] == square[2] && square[2] == square[3])
return 1;
else if (square[4] == square[5] && square[5] == square[6])
return 1;
else if (square[7] == square[8] && square[8] == square[9])
return 1;
else if (square[1] == square[4] && square[4] == square[7])
return 1;
else if (square[2] == square[5] && square[5] == square[8])
return 1;
else if (square[3] == square[6] && square[6] == square[9])
return 1;
else if (square[1] == square[5] && square[5] == square[9])
return 1;
else if (square[3] == square[5] && square[5] == square[7])
return 1;
else
return - 1;
}

Square[10] Array
This array is used to show entries done by players
as well as position of empty space present in tic
tac toe board during game.
Its size is 10 to avoid confusing while writing the
conditions in the checkwin function so that at index
i , character i can be stored.

char square[10] = { 'o', '1', '2', '3', '4', '5', '6', '7', '8', '9' };

Do while loop
This loop is used to
 interchange the turn of players
 enter X or O
 check whether the player is doing a valid
move

Do while loop Body


do
{
board();
player = (player % 2) ? 1 : 2;

printf("Player %d, enter a number: ", player);


scanf("%d", &choice);

mark = (player == 1) ? 'X' : 'O';

if (choice == 1 && square[1] == '1')


square[1] = mark;

else if (choice == 2 && square[2] == '2')


square[2] = mark;

else if (choice == 3 && square[3] == '3')


square[3] = mark;

else if (choice == 4 && square[4] == '4')


square[4] = mark;

else if (choice == 5 && square[5] == '5')


square[5] = mark;

else if (choice == 6 && square[6] == '6')


square[6] = mark;

else if (choice == 7 && square[7] == '7')


square[7] = mark;

else if (choice == 8 && square[8] == '8')


square[8] = mark;

else if (choice == 9 && square[9] == '9')


square[9] = mark;

else
{
printf("Invalid move ");

player--;
count--;
getch();
}
i = checkwin();

player++;
count++;

}while (i == - 1&&count<=8);

CONCLUSION
This project is good for beginners to
understand various concept’s of c
programming language and also about
tic tac toe.

REFERENCE
1. GOOGLE
2.WIKIPEDIA
3.LET US “C” by Yashwant Kanetkar

You might also like