SlideShare a Scribd company logo
Aryabhatta International College
of Technical Education
Ajmer, Rajasthan
A
PROJECT REPORT
ON
Tic Tac Toe: C++
Submitted in partial fulfilment for the
Award of the Degree of
BACHELOR OF COMPUTER APPLICATIONS
2017-2018
Submitted to:
Aryabhatta International College of Technical Education
Submitted by:
Harshita Bhargava
ACKNOWLEDGEMENT
I am thankful to Kriti Sankhla Ma’am for her valuable time she has devoted to
me and given me a lot of knowledge and help for the project. I am also thankful
to other teachers for their expert guidance. It was a great experience for me to
work and learn under their guidance.
Words defeat us in expressing our deep sense of gratitude for our friends, whose
continued resourceful support and guidance enabled me to overcome all the
challenges that I have faced while developing the project.
Harshita Bhargava
TIC TAC TOE
#include<iostream.h>
#include<conio.h>
char a[10]={'0','1','2','3','4','5','6','7','8','9'};
class Tic_tac
{
private:
int player,choice,i;
char mark;
public:
void board();
void game();
int checkwin();
};
Tic_tac obj;
void Tic_tac::game()
{
clrscr();
int player=1;
int choice,i;
char mark;
obj.board();
do
{
player=(player%2==1)?1:2;
cout<<endl<<"Player "<<player<<endl<<"Enter a number:";
cin>>choice;
mark=(player==1)?'X':'O';
if(choice==1 && a[1]=='1')
{
a[1]=mark;
}
else if(choice==2 && a[2]=='2')
{
a[2]=mark;
}
else if(choice==3 && a[3]=='3')
{
a[3]=mark;
}
else if(choice==4 && a[4]=='4')
{
a[4]=mark;
}
else if(choice==5 && a[5]=='5')
{
a[5]=mark;
}
else if(choice==6 && a[6]=='6')
{
a[6]=mark;
}
else if(choice==7 && a[7]=='7')
{
a[7]=mark;
}
else if(choice==8 && a[8]=='8')
{
a[8]=mark;
}
else if(choice==9 && a[9]=='9')
{
a[9]=mark;
}
else
{
cout<<"Invalid Move";
player--;
}
player++;
i=checkwin();
clrscr();
board();
}while(i==-1);
if(i==1)
{
player--;
cout<<endl<<"---Player "<<player<<" win--- "<<endl;
}
else
{
cout<<"Game Draw"<<endl;
}
}
int Tic_tac::checkwin()
{
if(a[1]==a[2] && a[2]==a[3])
{
return 1;
}
else if(a[4]==a[5] && a[5]==a[6])
{
return 1;
}
else if(a[7]==a[8] && a[8]==a[9])
{
return 1;
}
else if(a[1]==a[4] && a[4]==a[7])
{
return 1;
}
else if(a[2]==a[5] && a[5]==a[8])
{
return 1;
}
else if(a[3]==a[6] && a[6]==a[9])
{
return 1;
}
else if(a[1]==a[5] && a[5]==a[9])
{
return 1;
}
else if(a[3]==a[5] && a[5]==a[6])
{
return 1;
}
else if(a[1]!='1' && a[2]!='2' && a[3]!='3' && a[4]!='4' && a[5]!='5' &&
a[6]!='6' && a[7]!='7' && a[8]!='8'&& a[9]!='9')
{
return 0;
}
else
{
return -1;
}
}
void Tic_tac::board()
{
cout<<endl;
cout<<"*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*"<<endl;
cout<<" TIC TAC TOE "<<endl;
cout<<"*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
*-*-*-*-*-*-*-*-*"<<endl<<endl;
cout<<" Player 1(X) Player 2(O)"<<endl<<endl<<endl;
cout<<" | | "<<endl;
cout<<" "<<a[1]<<" | "<<a[2]<<" | "<<a[3]<<endl;
cout<<" | | "<<endl;
cout<<" -----------------"<<endl;
cout<<" | | "<<endl;
cout<<" "<<a[4]<<" | "<<a[5]<<" | "<<a[6]<<endl;
cout<<" | | "<<endl;
cout<<" -----------------"<<endl;
cout<<" | | "<<endl;
cout<<" "<<a[7]<<" | "<<a[8]<<" | "<<a[9]<<endl;
cout<<" | | "<<endl;
}
void main()
{
clrscr();
obj.board();
obj.game();
obj.checkwin();
getch();
}
Output :-
Created by:
Harshita Bhargava

More Related Content

Similar to Tic tac toe

Similar to Tic tac toe (20)

College menagement system
College menagement systemCollege menagement system
College menagement system
 
JAYAPRAKASH_CV[1].net
JAYAPRAKASH_CV[1].netJAYAPRAKASH_CV[1].net
JAYAPRAKASH_CV[1].net
 
Bank Management System
Bank Management SystemBank Management System
Bank Management System
 
Venkatesh mani resume
Venkatesh mani resumeVenkatesh mani resume
Venkatesh mani resume
 
Delta ceramic 3 d printer
Delta ceramic 3 d printerDelta ceramic 3 d printer
Delta ceramic 3 d printer
 
sandeep resume
sandeep resumesandeep resume
sandeep resume
 
Prabhu's Resume - October
Prabhu's Resume - OctoberPrabhu's Resume - October
Prabhu's Resume - October
 
Rupesh_resume (1)
Rupesh_resume (1)Rupesh_resume (1)
Rupesh_resume (1)
 
Shopping mall management
Shopping mall managementShopping mall management
Shopping mall management
 
Shankho's resume
Shankho's resumeShankho's resume
Shankho's resume
 
aditya_resume
aditya_resumeaditya_resume
aditya_resume
 
Ankur_Saxena
Ankur_SaxenaAnkur_Saxena
Ankur_Saxena
 
Tanzil Khan resume
Tanzil Khan resumeTanzil Khan resume
Tanzil Khan resume
 
My Updated CV
My Updated CVMy Updated CV
My Updated CV
 
RAMYA_KV_em
RAMYA_KV_emRAMYA_KV_em
RAMYA_KV_em
 
RAMYA_KV_em
RAMYA_KV_emRAMYA_KV_em
RAMYA_KV_em
 
Rajkiran Patil
Rajkiran Patil Rajkiran Patil
Rajkiran Patil
 
Sourov_Pramanik_Resume
Sourov_Pramanik_ResumeSourov_Pramanik_Resume
Sourov_Pramanik_Resume
 
Info session- GDSC SSEC
Info session- GDSC SSECInfo session- GDSC SSEC
Info session- GDSC SSEC
 
RESUME 1
RESUME 1RESUME 1
RESUME 1
 

Recently uploaded

GraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisGraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisNeo4j
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion Clinic
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareinfo611746
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEJelle | Nordend
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAlluxio, Inc.
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowPeter Caitens
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...Alluxio, Inc.
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamtakuyayamamoto1800
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandIES VE
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationWave PLM
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessWSO2
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...rajkumar669520
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfMeon Technology
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...informapgpstrackings
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?XfilesPro
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
 

Recently uploaded (20)

GraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisGraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysis
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM Integration
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdf
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 

Tic tac toe

  • 1. Aryabhatta International College of Technical Education Ajmer, Rajasthan A PROJECT REPORT ON Tic Tac Toe: C++ Submitted in partial fulfilment for the Award of the Degree of BACHELOR OF COMPUTER APPLICATIONS 2017-2018 Submitted to: Aryabhatta International College of Technical Education Submitted by: Harshita Bhargava
  • 2. ACKNOWLEDGEMENT I am thankful to Kriti Sankhla Ma’am for her valuable time she has devoted to me and given me a lot of knowledge and help for the project. I am also thankful to other teachers for their expert guidance. It was a great experience for me to work and learn under their guidance. Words defeat us in expressing our deep sense of gratitude for our friends, whose continued resourceful support and guidance enabled me to overcome all the challenges that I have faced while developing the project. Harshita Bhargava
  • 3. TIC TAC TOE #include<iostream.h> #include<conio.h> char a[10]={'0','1','2','3','4','5','6','7','8','9'}; class Tic_tac { private: int player,choice,i; char mark; public: void board(); void game(); int checkwin(); }; Tic_tac obj; void Tic_tac::game() { clrscr(); int player=1; int choice,i; char mark; obj.board(); do { player=(player%2==1)?1:2; cout<<endl<<"Player "<<player<<endl<<"Enter a number:";
  • 4. cin>>choice; mark=(player==1)?'X':'O'; if(choice==1 && a[1]=='1') { a[1]=mark; } else if(choice==2 && a[2]=='2') { a[2]=mark; } else if(choice==3 && a[3]=='3') { a[3]=mark; } else if(choice==4 && a[4]=='4') { a[4]=mark; } else if(choice==5 && a[5]=='5') { a[5]=mark; } else if(choice==6 && a[6]=='6') { a[6]=mark; } else if(choice==7 && a[7]=='7') {
  • 5. a[7]=mark; } else if(choice==8 && a[8]=='8') { a[8]=mark; } else if(choice==9 && a[9]=='9') { a[9]=mark; } else { cout<<"Invalid Move"; player--; } player++; i=checkwin(); clrscr(); board(); }while(i==-1); if(i==1) { player--; cout<<endl<<"---Player "<<player<<" win--- "<<endl; } else { cout<<"Game Draw"<<endl;
  • 6. } } int Tic_tac::checkwin() { if(a[1]==a[2] && a[2]==a[3]) { return 1; } else if(a[4]==a[5] && a[5]==a[6]) { return 1; } else if(a[7]==a[8] && a[8]==a[9]) { return 1; } else if(a[1]==a[4] && a[4]==a[7]) { return 1; } else if(a[2]==a[5] && a[5]==a[8]) { return 1; } else if(a[3]==a[6] && a[6]==a[9]) { return 1;
  • 7. } else if(a[1]==a[5] && a[5]==a[9]) { return 1; } else if(a[3]==a[5] && a[5]==a[6]) { return 1; } else if(a[1]!='1' && a[2]!='2' && a[3]!='3' && a[4]!='4' && a[5]!='5' && a[6]!='6' && a[7]!='7' && a[8]!='8'&& a[9]!='9') { return 0; } else { return -1; } } void Tic_tac::board() { cout<<endl; cout<<"*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- *-*-*-*-*-*-*-*-*"<<endl; cout<<" TIC TAC TOE "<<endl; cout<<"*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- *-*-*-*-*-*-*-*-*"<<endl<<endl; cout<<" Player 1(X) Player 2(O)"<<endl<<endl<<endl;
  • 8. cout<<" | | "<<endl; cout<<" "<<a[1]<<" | "<<a[2]<<" | "<<a[3]<<endl; cout<<" | | "<<endl; cout<<" -----------------"<<endl; cout<<" | | "<<endl; cout<<" "<<a[4]<<" | "<<a[5]<<" | "<<a[6]<<endl; cout<<" | | "<<endl; cout<<" -----------------"<<endl; cout<<" | | "<<endl; cout<<" "<<a[7]<<" | "<<a[8]<<" | "<<a[9]<<endl; cout<<" | | "<<endl; } void main() { clrscr(); obj.board(); obj.game(); obj.checkwin(); getch(); }