SlideShare ist ein Scribd-Unternehmen logo
1 von 10
Aryabhatta International College of Technical Education
Ajmer, Rajasthan
A
PROJECT REPORT
ON
TIC TAC TOE Game: C++
Submitted in partial fulfilment for
Award of the Degree of 2017 Year,
BACHELOR OF COMPUTER APPLICATION
Submitted to
Aryabhatta International of College Technical Education
Submitted by:
Riddhi Chouhan
ACKNOWLEDGEMENT
I am Riddhi Chouhan Student of Bachelor’s of computer application
Aryabhatta International College Of Technical Education would like to
express my gratitude to each and every person who has contributed in
stimulating suggestions and encouragement which really helped me to
co-ordinate my project.
I also thank Aryabhatta International College Of Technical Education who
provided insight and expertise that greatly assisted the project. Also, a
special thanks to my teacher, parents and colleagues who have supported me
at every step.
Not to forget, the almighty who blessed me with good health becauseof
which I worked more I worked more efficiently and better
TIC TAC TOE Game :
Start Game:
Win Game:
Draw Game:
Code:
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
char square[10] = {'o','1','2','3','4','5','6','7','8','9'};
int checkwin();
void board();
int main()
{
clrscr();
int player = 1,i,choice;
char mark;
do
{
board();
player=(player%2)?1:2;
gotoxy(10,20);
cout << "Player " << player << ", enter a number: ";
cin >> choice;
mark=(player == 1) ?'X' : '0';
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--;
cin.ignore();
cin.get();
}
i=checkwin();
player++;
}while(i==-1);
board();
if(i==1)
{
gotoxy(35,24);
cout<<"==>aPlayer "<<--player<<" win ";
}
else
{
gotoxy(35,24);
cout<<"==>aGame draw";
}
cin.ignore();
cin.get();
return 0;
}
int checkwin()
{
clrscr();
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;
}
void board()
{
int i;
clrscr();
gotoxy(36,5);
cout << "Tic Tac Toenn";
gotoxy(27,7);
cout << "Player 1 (X) - Player 2 (O)";
gotoxy(33,10);
cout << " " << square[1] << " | " << square[2] << " | " << square[3] << endl;
gotoxy(33,13);
cout << " " << square[4] << " | " << square[5] << " | " << square[6] << endl;
gotoxy(33,16);
cout << " " << square[7] << " | " << square[8] << " | " << square[9] << endl;
gotoxy(33,11);
for(i=0;i<=17;i++)
{
cprintf("%c",220);
}
gotoxy(33,14);
for(i=0;i<=17;i++)
{
cprintf("%c",220);
}
gotoxy(33,8);
for(i=0;i<=17;i++)
{
cprintf("%c",220);
}
gotoxy(33,17);
for(i=0;i<=17;i++)
{
cprintf("%c",220);
}
for(i=9;i<=17;i++)
{
gotoxy(32,i);
cprintf("%c",219);
}
for(i=9;i<=17;i++)
{
gotoxy(50,i);
cprintf("%c",219);
}
for(i=9;i<=17;i++)
{
gotoxy(38,i);
cprintf("%c",219);
}
for(i=9;i<=17;i++)
{
gotoxy(44,i);
cprintf("%c",219);
}
gotoxy(50,8);
cprintf("%c",220);
gotoxy(32,8);
cprintf("%c",220);
}
Thank you
Created By :-Riddhi Chouhan
Aryabhatta International College of Technical
Education

Weitere ähnliche Inhalte

Ähnlich wie Tik tic tok

Tic tac toe on c++ project
Tic tac toe on c++ projectTic tac toe on c++ project
Tic tac toe on c++ projectUtkarsh Aggarwal
 
c++ project
c++ projectc++ project
c++ projectTrish004
 
Hardik Jadam , BCA Third Year
Hardik Jadam , BCA Third YearHardik Jadam , BCA Third Year
Hardik Jadam , BCA Third YearDezyneecole
 
Pooja Sharma , BCA Third Year
Pooja Sharma , BCA Third YearPooja Sharma , BCA Third Year
Pooja Sharma , BCA Third YearDezyneecole
 
SALARY MANAGEMENT SYSTEM IN C++
SALARY MANAGEMENT SYSTEM IN C++SALARY MANAGEMENT SYSTEM IN C++
SALARY MANAGEMENT SYSTEM IN C++vikram mahendra
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical fileMitul Patel
 
Game programming-help
Game programming-helpGame programming-help
Game programming-helpSteve Nash
 
Shikh Mohammad Usman Haidar , BCA Third Year
Shikh Mohammad Usman Haidar , BCA Third YearShikh Mohammad Usman Haidar , BCA Third Year
Shikh Mohammad Usman Haidar , BCA Third YearDezyneecole
 
CANTEEN MANAGEMENT SYSTEM IN C++
CANTEEN MANAGEMENT SYSTEM IN C++CANTEEN MANAGEMENT SYSTEM IN C++
CANTEEN MANAGEMENT SYSTEM IN C++vikram mahendra
 
Vinita Vaishnav , BCA Third Year
Vinita Vaishnav , BCA Third YearVinita Vaishnav , BCA Third Year
Vinita Vaishnav , BCA Third YearDezyneecole
 
Hardik Jadam , BCA Third Year
Hardik Jadam , BCA Third YearHardik Jadam , BCA Third Year
Hardik Jadam , BCA Third YearDezyneecole
 
ANS#include iostream int Rn_get(int low, int high); int cva.pdf
ANS#include iostream int Rn_get(int low, int high); int cva.pdfANS#include iostream int Rn_get(int low, int high); int cva.pdf
ANS#include iostream int Rn_get(int low, int high); int cva.pdfanikkothari1
 
New Tools for a More Functional C++
New Tools for a More Functional C++New Tools for a More Functional C++
New Tools for a More Functional C++Sumant Tambe
 
Gaurav Jatav , BCA Third Year
Gaurav Jatav , BCA Third YearGaurav Jatav , BCA Third Year
Gaurav Jatav , BCA Third Yeardezyneecole
 
The main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfThe main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfasif1401
 
Shivani Chouhan , BCA Third Year
Shivani Chouhan , BCA Third YearShivani Chouhan , BCA Third Year
Shivani Chouhan , BCA Third YearDezyneecole
 
COMPUTER SCIENCE INVESTIGATORY PROJECT ON FOOTBALL GAME AND SCORE MANAGEMENT ...
COMPUTER SCIENCE INVESTIGATORY PROJECT ON FOOTBALL GAME AND SCORE MANAGEMENT ...COMPUTER SCIENCE INVESTIGATORY PROJECT ON FOOTBALL GAME AND SCORE MANAGEMENT ...
COMPUTER SCIENCE INVESTIGATORY PROJECT ON FOOTBALL GAME AND SCORE MANAGEMENT ...pankajkumbara
 
include ltstdiohgt include ltstdlibhgt include .pdf
include ltstdiohgt include ltstdlibhgt include .pdfinclude ltstdiohgt include ltstdlibhgt include .pdf
include ltstdiohgt include ltstdlibhgt include .pdfadisainternational
 

Ähnlich wie Tik tic tok (20)

Tic tac toe on c++ project
Tic tac toe on c++ projectTic tac toe on c++ project
Tic tac toe on c++ project
 
c++ project
c++ projectc++ project
c++ project
 
Hardik Jadam , BCA Third Year
Hardik Jadam , BCA Third YearHardik Jadam , BCA Third Year
Hardik Jadam , BCA Third Year
 
Pooja Sharma , BCA Third Year
Pooja Sharma , BCA Third YearPooja Sharma , BCA Third Year
Pooja Sharma , BCA Third Year
 
SALARY MANAGEMENT SYSTEM IN C++
SALARY MANAGEMENT SYSTEM IN C++SALARY MANAGEMENT SYSTEM IN C++
SALARY MANAGEMENT SYSTEM IN C++
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
 
Game programming-help
Game programming-helpGame programming-help
Game programming-help
 
Shikh Mohammad Usman Haidar , BCA Third Year
Shikh Mohammad Usman Haidar , BCA Third YearShikh Mohammad Usman Haidar , BCA Third Year
Shikh Mohammad Usman Haidar , BCA Third Year
 
CANTEEN MANAGEMENT SYSTEM IN C++
CANTEEN MANAGEMENT SYSTEM IN C++CANTEEN MANAGEMENT SYSTEM IN C++
CANTEEN MANAGEMENT SYSTEM IN C++
 
Vinita Vaishnav , BCA Third Year
Vinita Vaishnav , BCA Third YearVinita Vaishnav , BCA Third Year
Vinita Vaishnav , BCA Third Year
 
Hardik Jadam , BCA Third Year
Hardik Jadam , BCA Third YearHardik Jadam , BCA Third Year
Hardik Jadam , BCA Third Year
 
ANS#include iostream int Rn_get(int low, int high); int cva.pdf
ANS#include iostream int Rn_get(int low, int high); int cva.pdfANS#include iostream int Rn_get(int low, int high); int cva.pdf
ANS#include iostream int Rn_get(int low, int high); int cva.pdf
 
New Tools for a More Functional C++
New Tools for a More Functional C++New Tools for a More Functional C++
New Tools for a More Functional C++
 
Gaurav Jatav , BCA Third Year
Gaurav Jatav , BCA Third YearGaurav Jatav , BCA Third Year
Gaurav Jatav , BCA Third Year
 
The main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfThe main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdf
 
Shivani Chouhan , BCA Third Year
Shivani Chouhan , BCA Third YearShivani Chouhan , BCA Third Year
Shivani Chouhan , BCA Third Year
 
COMPUTER SCIENCE INVESTIGATORY PROJECT ON FOOTBALL GAME AND SCORE MANAGEMENT ...
COMPUTER SCIENCE INVESTIGATORY PROJECT ON FOOTBALL GAME AND SCORE MANAGEMENT ...COMPUTER SCIENCE INVESTIGATORY PROJECT ON FOOTBALL GAME AND SCORE MANAGEMENT ...
COMPUTER SCIENCE INVESTIGATORY PROJECT ON FOOTBALL GAME AND SCORE MANAGEMENT ...
 
include ltstdiohgt include ltstdlibhgt include .pdf
include ltstdiohgt include ltstdlibhgt include .pdfinclude ltstdiohgt include ltstdlibhgt include .pdf
include ltstdiohgt include ltstdlibhgt include .pdf
 
Online exam
Online examOnline exam
Online exam
 
Tic tac toe
Tic tac toeTic tac toe
Tic tac toe
 

Kürzlich hochgeladen

What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 

Kürzlich hochgeladen (20)

What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 

Tik tic tok

  • 1. Aryabhatta International College of Technical Education Ajmer, Rajasthan A PROJECT REPORT ON TIC TAC TOE Game: C++ Submitted in partial fulfilment for Award of the Degree of 2017 Year, BACHELOR OF COMPUTER APPLICATION Submitted to Aryabhatta International of College Technical Education Submitted by: Riddhi Chouhan
  • 2. ACKNOWLEDGEMENT I am Riddhi Chouhan Student of Bachelor’s of computer application Aryabhatta International College Of Technical Education would like to express my gratitude to each and every person who has contributed in stimulating suggestions and encouragement which really helped me to co-ordinate my project. I also thank Aryabhatta International College Of Technical Education who provided insight and expertise that greatly assisted the project. Also, a special thanks to my teacher, parents and colleagues who have supported me at every step. Not to forget, the almighty who blessed me with good health becauseof which I worked more I worked more efficiently and better
  • 3. TIC TAC TOE Game : Start Game: Win Game:
  • 4. Draw Game: Code: #include<iostream.h> #include<conio.h> #include<stdlib.h> char square[10] = {'o','1','2','3','4','5','6','7','8','9'}; int checkwin(); void board(); int main() { clrscr(); int player = 1,i,choice; char mark; do { board(); player=(player%2)?1:2;
  • 5. gotoxy(10,20); cout << "Player " << player << ", enter a number: "; cin >> choice; mark=(player == 1) ?'X' : '0'; 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
  • 6. { cout<<"Invalid move "; player--; cin.ignore(); cin.get(); } i=checkwin(); player++; }while(i==-1); board(); if(i==1) { gotoxy(35,24); cout<<"==>aPlayer "<<--player<<" win "; } else { gotoxy(35,24); cout<<"==>aGame draw"; } cin.ignore(); cin.get(); return 0; } int checkwin() { clrscr(); if (square[1] == square[2] && square[2] == square[3])
  • 7. 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; } void board() {
  • 8. int i; clrscr(); gotoxy(36,5); cout << "Tic Tac Toenn"; gotoxy(27,7); cout << "Player 1 (X) - Player 2 (O)"; gotoxy(33,10); cout << " " << square[1] << " | " << square[2] << " | " << square[3] << endl; gotoxy(33,13); cout << " " << square[4] << " | " << square[5] << " | " << square[6] << endl; gotoxy(33,16); cout << " " << square[7] << " | " << square[8] << " | " << square[9] << endl; gotoxy(33,11); for(i=0;i<=17;i++) { cprintf("%c",220); } gotoxy(33,14); for(i=0;i<=17;i++) { cprintf("%c",220); } gotoxy(33,8); for(i=0;i<=17;i++) { cprintf("%c",220); } gotoxy(33,17); for(i=0;i<=17;i++) {
  • 10. Thank you Created By :-Riddhi Chouhan Aryabhatta International College of Technical Education