Documente Academic
Documente Profesional
Documente Cultură
Submitted By
RUPESH KUMAR PANDEY
Class: XII B
Under the Guidance of
Mrs. Anshu Rani
PGT (Computer Science)
Department of Computer Science
Kendriya Vidyalaya Air Force Station
Bidar, KARNATAKA.
CERTIFICAT
E
The project report entitled
Tic Tac Toe game,
SIGNATURE OF EXAMINER
D E C LAR AT I O N
I hereby declare that the project work entitled
TIC TAC TOE GAME, submitted to
Department of Computer Science, Kendriya
Vidyalaya AFS Bidar Karnataka is prepared by
me. All the coding is result of my personal
efforts.
RUPESH KUMAR
PANDEY
Class XII B
ACKNOWLEDGEMENT
I would like to express a deep sense of thanks & gratitude to my
project guide Mrs.Anshu Rani for guiding me immensely through the
course of the project. She always evinced keen interest in my work. His
constructive advice & constant motivation have been responsible for the
successful completion of this project.
My sincere thanks goes to Shri Krishna Kumar K.K, Our principal
sir, for his co-ordination in extending every possible support for the
completion of this project.
I also thanks to my parents for their motivation & support. I must
thanks to my classmates for their timely help & support for compilation
of this project.
Last but not the least, I would like to thank all those who had
helped directly or indirectly towards the completion of this project.
CONTENTS
2. WORKING DESCRIPTION. . . . . . . . . . . . .
3. CODING . . . . . . . . . .. . . . . . . . . . . . . . . .
4. OUTPUT SCREENS. . . . . . . . . . . . . . . . . . .
....
5. BIBLIOGRAPHY. . . . . . . . . . . . . . . . . . . . .
....
doing
mathematical
WORKING DESCRIPTION
3.
4.
CODING
#include <fstream.h>
#include <conio.h>
#include<process.h>
#include<math.h>
#include<stdio.h>
#include<stdlib.h>
char square[10] = {'o','1','2','3','4','5','6','7','8','9'};
int checkwin();
void board();
int main()
{
int player = 1,i,choice;
char mark;
clrscr();
do
{
board();
player=(player%2)?1:2;
cout << "Player " << player << ", enter a
number: ";
cin >> 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')
else
else
else
else
else
else
else
{
";
square[3] = mark;
if (choice == 4 && square[4]
square[4] = mark;
if (choice == 5 && square[5]
square[5] = mark;
if (choice == 6 && square[6]
square[6] = mark;
if (choice == 7 && square[7]
square[7] = mark;
if (choice == 8 && square[8]
square[8] = mark;
if (choice == 9 && square[9]
square[9] = mark;
== '4')
== '5')
== '6')
== '7')
== '8')
== '9')
}
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
O GAME IS OVER AND NO RESULT
**********************************************/
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 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;
}
/
*******************************************************
************
FUNCTION TO DRAW BOARD OF TIC TAC TOE
WITH PLAYERS MARK
*******************************************************
*************/
void board()
{
clrscr();
cout <<
cout <<
<< endl;
cout <<
cout <<
cout << " " << square[1] << " | " <<
square[2] << " | " << square[3] << endl;
cout << "_____|_____|_____" << endl;
cout << "
|
|
" << endl;
cout << " " << square[4] << " | " <<
square[5] << " | " << square[6] << endl;
cout << "_____|_____|_____" << endl;
cout << "
|
|
" << endl;
cout << " " << square[7] << " | " <<
square[8] << " | " << square[9] << endl;
cout << "
|
|
" << endl << endl;
}
/
*******************************************************
************
END OF PROJECT
*******************************************************
*************/
OUTPUT
SCREEN
1) PLAYER 1 ENTER
A NUMBER.
2)PLAYER 1 ENTERS
1
3)PLAYER 2 ENTER A
NUMBER
4)PLAYER 2 ENTERS
6
5)PLAYER 1 ENTER A
NUMBER
6)PLAYER 1 ENTERS
2
7)PLAYER 2 ENTER A
NUMBER
8)PLAYER 2 ENTERS
8
9)PLAYER 1 ENTER A
NUMBER
10)PLAYER 1
ENTERS 3
11)PLAYER 1 WINS
THE GAME
BIBLIOGRAP
HY
1)SL ARORA TEXT.
2)SEEMA
BHATNAGARS
BOOK
3)WWW.CPPSCHO
OL.COM
4)WWW.ICBSE.CO
M