ACKNOWLEDGEMENT
We, the members of this project, acknowledge the valuable contribution
of the individuals involved in the development of this project. We are
grateful to our computer and project instructor DEBAJIT DEY for his
continuous support for the project from the initial advice to this present
day. Sincere thanks & gratitude from us goes to our Principal Ma’am
Mrs. Swapna Shome for her encouragement and the required facilities
that she provided for the improvement of this project. We sincerely
appreciate this magnanimity by taking us into her fold for which, we
shall remain indebted to her.
We would also like to thank our parents for their undivided support and
interest and also providing the necessary facilities regarding financial
matters. At last we would like to thank our friends for motivating us.
The contribution of the printing department in bringing this project are
also duly acknowledged.
1|TIC-TAC-TOE
CERTIFICATE OF APPROVAL
The Project ‘TIC-TAC-TOE’ is hereby approved as a credible study of
Computer Science carried out by:
(1) Prantik Chakraborty
(2) Bishal Paul
(3) Debajit Ghosh
(4) SamratSaha
(5) SubhasishBhowmik
And presented in a manner satisfactory to warrant its acceptance as
prerequisite to the marks for which it has been submitted. It is
understood by this approval that the undersigned do not endorse or
approve any statement made, opinion of conclusion drawn therein but
approve only for the purpose for which it has been submitted.
MENTOR: Signature of Principal
Debajit Dey ______________________
2|TIC-TAC-TOE
CANDIDATES DECLARATION
This report is prepared to certify that, the members of this project-
PRANTIK CHAKRABORTY, BISHAL PAUL, DEBAJIT GHOSH,
SAMRAT SAHA, SUBHASISH BHOWMIK, students of class XI-
Science,
has successfully and sincerely done this project based on this topic
‘TIC-TAC-TOE’ under proper guidance and supervision of DEBAJIT
DEY, Computer teacher.
PRANTIK CHAKRABORTY: ___________________
BISHAL PAUL: ___________________
DEBAJIT GHOSH: ___________________
SAMRAT SAHA: ___________________
SUBHASISH BHOWMIK: ___________________
3|TIC-TAC-TOE
CONTENTS
Page
SL.NO. TITLE No.
1. OVERVIEW OF C++ 5
2. PROGRAMMING METHODOLOGY 6
3. SOFTWARE REQUIREMENTS 7
4. PURPOSE OF HEADER FILES USED 8
5. INTRODUCTION TO TIC-TAC-TOE 9
10-15
6. SOURCE CODE
16-20
7. OUTPUT
8. CONCLUSION 21
9. BIBLIOGRAPHY 22
4|TIC-TAC-TOE
OVERVIEW OF C++
C++ is a general purpose programming language. It has imperative,
object-oriented and generic programming features, while also providing the
facilities for low level memory manipulation.
It is designed with a bias for systems programming with performance,
efficiency & flexibility of use as its design requirements. C++ has also been
useful in many other contexts, including computer application, server,
performance, critical applications & entertaining software.
It is a compiled language, with implementation of its available on many
platforms. Various organization provide them including the FSF, LLVM,
Microsoft & Intel.
C++ is standardized by the International Organization for
Standardization(ISO),which is the latest having being ratified and
published by ISO in September 2011 as ISO/IEC 14882:20011. The C++
programming language was initially standardized in 1998 as ISO/IEC
14882:2003, standard. The standard supersedes these with new features and
standard library.
Before standardization, C++ was developed by Bjarne Stoustrup at Bell
Labs, starting in 1979, who wanted an efficient flexible language(like C) that
also provided high level features for program organization.
5|TIC-TAC-TOE
PROGRAMMING METHODOLOGY
Object Oriented Programming(OOP) is a design philosophy. OOP uses a
different set of programming languages than old procedural programming
languages(C,Pascal,etc). Everything in OOP is grouped as sustainable
‘objects’. Hence, you gain re-usability by means of four OOP concepts.
In order to clearly understand the object orientation, let’s take your ‘hands’ as
example, the ‘hand’ is a class. Your body has two objects of type hand, named
left hand and right hand. Their functions are controlled/managed by the set of
electrical signals sent through your shoulders(through an interface). So, the
shoulder is an interface which your body uses to interact with your hand. The
hand is being copied to create the left hand and the right hand by slightly
changing the properties of it.
6|TIC-TAC-TOE
SOFTWARE REQUIREMENTS
REQUIREMENTS:
Minimum Recommended
OS: Windows Vista Windows 8 or Windows 10
RAM: 512MB 1GB
Turbo C++(ver. 2.0) Turbo C++(ver. 2.1)
Size on disk: ~15MB
7|TIC-TAC-TOE
PURPOSE OF HEADER FILES USED
#include<iostream.h>
<iostream.h> input output stream header file.
Provides functionality to use an abstraction called streams specially
designed to perform input output operations on sequences of character,
like flies or strings. Objects cin, cout, are from iostream header.
#include<conio.h>
It is often used to create text-based user interface. It has many functions
such as getch()which waits for a key to be pressed. It also has color related
functions. You can use them to change the color of the text or background
in a console application. It also has functions related to cursor movements,
such as gotoxy().
#include<string.h>
The string function performs string operations on null terminated strings.
8|TIC-TAC-TOE
INTRODUCTION TO
TIC-TAC-TOE
Tic-Tac-Toe(Noughts & Crosses or X & O)is a pencil & paper game for
two players, ‘X’&‘O’, who take turns making the spaces in a 3X3 grid.
The player who succeeds in placing 3 respective marks in a horizontal,
vertical, or diagonal row wins the game.
This program is a game program, Tic-Tac-Toe. We have made a C++
program on it.
This game uses board to control players. In each turn players enter a
number and choose a move. Simply programming assumes that player
one always moves first and uses ‘X’ & Player two moves at 2nd position
and uses ‘O’.
9|TIC-TAC-TOE
SOURCE CODE
#include<iostream.h>
#include<string.h>
#include<conio.h>
char
square[10]={'0','1','2','3','4','5','6','7','8','9'};
intcheckwin();
void board();
intmain()
{
int player=1,i,choice;
char mark;
clrscr();
do
{
board();
player=(player%2)?1:2;
cout<<"Player "<<player<<", Enter a Number:";
cin>>choice;
10 | T I C - T A C - T O E
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
{
cout<<"Invalid move";
player--;
getch();
}
11 | T I C - T A C - T O E
i=checkwin();
player++;
}while(i==-1);
board();
if(i==1)
cout<<"==>\aPlayer "<<--player<<" Win!";
else
cout<<"==>\aGame Draw";
getch();
return 0;
}
/****************************************************
FUNCTION TO RETURN GAME STATUS
1 FOR GAME IS OVER WITH RESULT
-1 FOR GAME IS IN PROGRESS
0 GAME IS OVER AND NO RESULT
****************************************************/
intcheckwin()
{
if(square[1]==square[2] && square[2]==square[3])
return 1;
else if(square[4]==square[5] &&
square[5]==square[6])
return 1;
12 | T I C - T A C - T O E
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 if(square[1]!='1'&& square[2]!='2'&&
square[3]!='3'&& square[4]!='4'&& square[5]!='5'&&
square[6]!='6'&& square[7]!='7'&& square[8]!='8'&&
square[9]!='9')
return 0;
else
return -1;
}
13 | T I C - T A C - T O E
/****************************************************
FUNCTION TO DRAW BOARD OF TIC TAC TOE WITH PLAYERS
MARK
****************************************************/
void board()
{
clrscr();
cout<<"\n\n\t TIC TAC TOE\n\n";
cout<<"\npresented by:\n\n 1.Prantik Chakraborty\t
2.Bishal Paul\t 3.Debajit Ghosh\n 4.Samrat Saha\t
5.Subhasish Bhowmik\n\n";
cout<<"Player 1 (X) - Player 2 (O)"<<endl<<endl;
cout<<endl;
cout<<" | | "<<endl;
cout<<" "<<square[1]<<" | "<<square[2]<<" |
"<<square[3]<<endl;
cout<<"___|___|___"<<endl;
cout<<" | | "<<endl;
cout<<" "<<square[4]<<" | "<<square[5]<<" |
"<<square[6]<<endl;
14 | T I C - T A C - T O E
cout<<"___|___|___"<<endl;
cout<<" | | "<<endl;
cout<<" "<<square[7]<<" | "<<square[8]<<" |
"<<square[9]<<endl;
cout<<" | | "<<endl<<endl;
}
15 | T I C - T A C - T O E
OUTPUT
(i)
(ii)
16 | T I C - T A C - T O E
(iii)
(iv)
17 | T I C - T A C - T O E
(v)
(vi)
18 | T I C - T A C - T O E
(vii)
(viii)
19 | T I C - T A C - T O E
(ix)
20 | T I C - T A C - T O E
CONCLUSION
Our program is basically a game known as Tic-Tac-Toe. This game is
basically of placing our choice so that our outcome comes horizontally,
vertically & diagonally. This is a game which even a kid can play
without recognition of any of the keys as their function. At last, we can
conclude that the project has been successfully completed as it ran
without any error.
21 | T I C - T A C - T O E
BIBLIOGRAPHY
To make this project we have taken help with the source from
Github.com & Stackoverflow.com.
And received guidance from our computer teacher Debajit Dey.
22 | T I C - T A C - T O E