SlideShare a Scribd company logo
INTRODUCTION:
Tic-tac-toe (or Noughts and crosses, Xs and Os) is a pencil-and-paper
game for two players, X and O, who take turns marking the spaces in a
3×3 grid. The player who succeeds in placing three respective marks in a
horizontal, vertical, or diagonal row wins the game.
This program is a game program, Tic Tac Toe. Most of us have played this
game in school days, I make a C++ program on it.
PURPOSE: The purpose of this game is how we can use
functions and the if , else if statements in C++ .
HOW TO PLAY:
 In this game we see (3*3)=9 square shape box's.
 The identify symbol of player 1 is ( X ),and player 2 is( O ).
 When player 1 enter a number (1-9) ,the symbol ( x ) take position in
that number.
 similarly player 2 enter his/her number, and the symbol ( O )take
that position which number he/she input.
 When a symbol ( X ) or ( O )full fill a column, row, or diagonal first
this symbol player will be win.
4 Major Part Of Program.
1.Char type global variable.
2.Main function
3. Checkwin function.
4. Board function.
1. Char type global variable:
In this program we use only 1 header file #include<iostream.h>,
because this header file is the definition of the input or output object.
After this I make a character type global variable starting 0 to 9.
MAJOR PART OF PROGRAM
DETAILS OF CODE
2.Main function: After this I declared 2 functions checkwin and
board.
After this the Main function is started Main logical and arithmetical steps
occurred in this function. I declared variables and assign player variable to
1.
I use do while loop in this program. First of all I call the board function to
display the main structure of game.
This function display the structure as :
After this first player enters a number (1 to 9) and the control according to
that number check the conditions that I made in the if else if structure . I
use a variable choice that save the number of user. And mark variable
assign player 1 X sign and 0 sign to second player. After the if else if
structure I mention if the user enter wrong number not from 1 to 9 then
computer display that the user enter invalid number. After this in each
case main function call the checkwin function that check any player wins
or not. If player is win then its display the result who is the winer with a
beep . and if there is not, then the game will be continue. The result of
checkwin function is save in the variable i and loop condition is running
until condition becomes false.
3.Checkwin function: It is the function, used for detecting the
winner or determining the drawn result. In this function all conditions are
given. Any condition is true then this function return the result 1 and loop
will be terminated and if the game draw the function return the result 0.
Or the game will be continue this function return -1 and loop will not be
terminated.
4.Board function: It is the function used for printing out playing
board.
COMPLETE SOURCE CODE
SCREEN SHOTS OF PROGRAM:
END
********************************************************

More Related Content

What's hot

LUDO BOARD GAME OPENGL COMPUTER GRAPHICS
LUDO BOARD GAME OPENGL COMPUTER GRAPHICSLUDO BOARD GAME OPENGL COMPUTER GRAPHICS
LUDO BOARD GAME OPENGL COMPUTER GRAPHICS
RAJEEV KUMAR SINGH
 
Java Guessing Game Number Tutorial
Java Guessing Game Number TutorialJava Guessing Game Number Tutorial
Java Guessing Game Number Tutorial
OXUS 20
 
Game Design - Lecture 1
Game Design - Lecture 1Game Design - Lecture 1
Game Design - Lecture 1
Andrea Resmini
 
Rock ,Paper, Scissors IAI .pptx
Rock ,Paper, Scissors IAI .pptxRock ,Paper, Scissors IAI .pptx
Rock ,Paper, Scissors IAI .pptx
Home
 
snake game
snake gamesnake game
snake game
Shailesh kumar
 
Tic Tac Toe Project
Tic Tac Toe Project Tic Tac Toe Project
Tic Tac Toe Project
KanikaJawla
 
Ppt. By Me.pptx
Ppt. By Me.pptxPpt. By Me.pptx
Ppt. By Me.pptx
UjjawalSingh77
 
Tic Tac Toe Java Development
Tic Tac Toe Java DevelopmentTic Tac Toe Java Development
Tic Tac Toe Java Development
pengqia chen
 
Black book
Black bookBlack book
Black book
PawanYadav348
 
Number Guessing Game
Number Guessing GameNumber Guessing Game
Number Guessing Game
Manish Kumar
 
Various Topics on Game Design
Various Topics on Game DesignVarious Topics on Game Design
Various Topics on Game Design
Martin Ruskov, PhD
 
Snake game powerpoint presentation by rohit malav
Snake game powerpoint presentation by rohit malavSnake game powerpoint presentation by rohit malav
Snake game powerpoint presentation by rohit malav
Rohit malav
 
Ball Collecting game report
Ball Collecting game report Ball Collecting game report
Ball Collecting game report
Dileep Maurya
 
Rock, Paper, Scissors
Rock, Paper, ScissorsRock, Paper, Scissors
Rock, Paper, ScissorsJohnathan
 
Tic Tac Toe ppt
Tic Tac Toe pptTic Tac Toe ppt
Tic Tac Toe ppt
SanchitRastogi15
 
Car racing game for android
Car racing game for androidCar racing game for android
Car racing game for android
ravijot singh
 
Tic tac toe
Tic tac toeTic tac toe
Tic tac toe
Upendra Sengar
 
Rock , paper and scissors game made with PYTHON
Rock , paper and  scissors game made with PYTHON Rock , paper and  scissors game made with PYTHON
Rock , paper and scissors game made with PYTHON
Home
 
Tic tac toe
Tic tac toeTic tac toe
Tic tac toe
Syeda Urooba
 

What's hot (20)

Tic Tac Toe
Tic Tac ToeTic Tac Toe
Tic Tac Toe
 
LUDO BOARD GAME OPENGL COMPUTER GRAPHICS
LUDO BOARD GAME OPENGL COMPUTER GRAPHICSLUDO BOARD GAME OPENGL COMPUTER GRAPHICS
LUDO BOARD GAME OPENGL COMPUTER GRAPHICS
 
Java Guessing Game Number Tutorial
Java Guessing Game Number TutorialJava Guessing Game Number Tutorial
Java Guessing Game Number Tutorial
 
Game Design - Lecture 1
Game Design - Lecture 1Game Design - Lecture 1
Game Design - Lecture 1
 
Rock ,Paper, Scissors IAI .pptx
Rock ,Paper, Scissors IAI .pptxRock ,Paper, Scissors IAI .pptx
Rock ,Paper, Scissors IAI .pptx
 
snake game
snake gamesnake game
snake game
 
Tic Tac Toe Project
Tic Tac Toe Project Tic Tac Toe Project
Tic Tac Toe Project
 
Ppt. By Me.pptx
Ppt. By Me.pptxPpt. By Me.pptx
Ppt. By Me.pptx
 
Tic Tac Toe Java Development
Tic Tac Toe Java DevelopmentTic Tac Toe Java Development
Tic Tac Toe Java Development
 
Black book
Black bookBlack book
Black book
 
Number Guessing Game
Number Guessing GameNumber Guessing Game
Number Guessing Game
 
Various Topics on Game Design
Various Topics on Game DesignVarious Topics on Game Design
Various Topics on Game Design
 
Snake game powerpoint presentation by rohit malav
Snake game powerpoint presentation by rohit malavSnake game powerpoint presentation by rohit malav
Snake game powerpoint presentation by rohit malav
 
Ball Collecting game report
Ball Collecting game report Ball Collecting game report
Ball Collecting game report
 
Rock, Paper, Scissors
Rock, Paper, ScissorsRock, Paper, Scissors
Rock, Paper, Scissors
 
Tic Tac Toe ppt
Tic Tac Toe pptTic Tac Toe ppt
Tic Tac Toe ppt
 
Car racing game for android
Car racing game for androidCar racing game for android
Car racing game for android
 
Tic tac toe
Tic tac toeTic tac toe
Tic tac toe
 
Rock , paper and scissors game made with PYTHON
Rock , paper and  scissors game made with PYTHON Rock , paper and  scissors game made with PYTHON
Rock , paper and scissors game made with PYTHON
 
Tic tac toe
Tic tac toeTic tac toe
Tic tac toe
 

Similar to C++ projct

Advanced level school Python programming. Needs helps. thanks in.pdf
Advanced level school Python programming.  Needs helps. thanks in.pdfAdvanced level school Python programming.  Needs helps. thanks in.pdf
Advanced level school Python programming. Needs helps. thanks in.pdf
deepakkhurana451
 
python.pptx
python.pptxpython.pptx
python.pptx
sreeshanthSingarapu
 
Modelling and implementation of 9tka game with MaxN algorithm
Modelling and implementation of 9tka game with MaxN algorithmModelling and implementation of 9tka game with MaxN algorithm
Modelling and implementation of 9tka game with MaxN algorithm
TELKOMNIKA JOURNAL
 
Artificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe gameArtificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe game
manika kumari
 
#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf
aquacareser
 
#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf
aquapariwar
 
Mine sweeper
Mine sweeperMine sweeper
Mine sweeper
Iffat Anjum
 
0-miniproject sem 4 review 1(1)(2).pptx
0-miniproject sem 4 review 1(1)(2).pptx0-miniproject sem 4 review 1(1)(2).pptx
0-miniproject sem 4 review 1(1)(2).pptx
AhishektttPhm
 
2nd National ArithmetEQ Challenge Rules
2nd National ArithmetEQ Challenge Rules2nd National ArithmetEQ Challenge Rules
2nd National ArithmetEQ Challenge Rules
Gomind
 
National ArithmetEQ Challenge Rules 2010
National ArithmetEQ Challenge Rules 2010National ArithmetEQ Challenge Rules 2010
National ArithmetEQ Challenge Rules 2010
guest1b4853
 
Artificial intelligence - python
Artificial intelligence - pythonArtificial intelligence - python
Artificial intelligence - python
Sunjid Hasan
 
MINI-MAX ALGORITHM.pptx
MINI-MAX ALGORITHM.pptxMINI-MAX ALGORITHM.pptx
MINI-MAX ALGORITHM.pptx
NayanChandak1
 
I have to write a Connect Four game program When a player t.pdf
I have to write a Connect Four game program When a player t.pdfI have to write a Connect Four game program When a player t.pdf
I have to write a Connect Four game program When a player t.pdf
aayushmaany2k14
 
Final Capstone Paper
Final Capstone PaperFinal Capstone Paper
Final Capstone PaperBrandon Lyles
 
Tugas 1 paal e agus budi raharjo 5109100164
Tugas 1 paal e agus budi raharjo 5109100164Tugas 1 paal e agus budi raharjo 5109100164
Tugas 1 paal e agus budi raharjo 5109100164Budi Raharjo
 
tic-tac-toe: Game playing
 tic-tac-toe: Game playing tic-tac-toe: Game playing
tic-tac-toe: Game playing
kalpana Manudhane
 

Similar to C++ projct (16)

Advanced level school Python programming. Needs helps. thanks in.pdf
Advanced level school Python programming.  Needs helps. thanks in.pdfAdvanced level school Python programming.  Needs helps. thanks in.pdf
Advanced level school Python programming. Needs helps. thanks in.pdf
 
python.pptx
python.pptxpython.pptx
python.pptx
 
Modelling and implementation of 9tka game with MaxN algorithm
Modelling and implementation of 9tka game with MaxN algorithmModelling and implementation of 9tka game with MaxN algorithm
Modelling and implementation of 9tka game with MaxN algorithm
 
Artificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe gameArtificial Intelligence- TicTacToe game
Artificial Intelligence- TicTacToe game
 
#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf
 
#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf#In this project you will write a program play TicTacToe #using tw.pdf
#In this project you will write a program play TicTacToe #using tw.pdf
 
Mine sweeper
Mine sweeperMine sweeper
Mine sweeper
 
0-miniproject sem 4 review 1(1)(2).pptx
0-miniproject sem 4 review 1(1)(2).pptx0-miniproject sem 4 review 1(1)(2).pptx
0-miniproject sem 4 review 1(1)(2).pptx
 
2nd National ArithmetEQ Challenge Rules
2nd National ArithmetEQ Challenge Rules2nd National ArithmetEQ Challenge Rules
2nd National ArithmetEQ Challenge Rules
 
National ArithmetEQ Challenge Rules 2010
National ArithmetEQ Challenge Rules 2010National ArithmetEQ Challenge Rules 2010
National ArithmetEQ Challenge Rules 2010
 
Artificial intelligence - python
Artificial intelligence - pythonArtificial intelligence - python
Artificial intelligence - python
 
MINI-MAX ALGORITHM.pptx
MINI-MAX ALGORITHM.pptxMINI-MAX ALGORITHM.pptx
MINI-MAX ALGORITHM.pptx
 
I have to write a Connect Four game program When a player t.pdf
I have to write a Connect Four game program When a player t.pdfI have to write a Connect Four game program When a player t.pdf
I have to write a Connect Four game program When a player t.pdf
 
Final Capstone Paper
Final Capstone PaperFinal Capstone Paper
Final Capstone Paper
 
Tugas 1 paal e agus budi raharjo 5109100164
Tugas 1 paal e agus budi raharjo 5109100164Tugas 1 paal e agus budi raharjo 5109100164
Tugas 1 paal e agus budi raharjo 5109100164
 
tic-tac-toe: Game playing
 tic-tac-toe: Game playing tic-tac-toe: Game playing
tic-tac-toe: Game playing
 

Recently uploaded

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 

Recently uploaded (20)

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 

C++ projct

  • 1. INTRODUCTION: Tic-tac-toe (or Noughts and crosses, Xs and Os) is a pencil-and-paper game for two players, X and O, who take turns marking the spaces in a 3×3 grid. The player who succeeds in placing three respective marks in a horizontal, vertical, or diagonal row wins the game. This program is a game program, Tic Tac Toe. Most of us have played this game in school days, I make a C++ program on it. PURPOSE: The purpose of this game is how we can use functions and the if , else if statements in C++ . HOW TO PLAY:  In this game we see (3*3)=9 square shape box's.  The identify symbol of player 1 is ( X ),and player 2 is( O ).  When player 1 enter a number (1-9) ,the symbol ( x ) take position in that number.
  • 2.  similarly player 2 enter his/her number, and the symbol ( O )take that position which number he/she input.  When a symbol ( X ) or ( O )full fill a column, row, or diagonal first this symbol player will be win. 4 Major Part Of Program. 1.Char type global variable. 2.Main function 3. Checkwin function. 4. Board function. 1. Char type global variable: In this program we use only 1 header file #include<iostream.h>, because this header file is the definition of the input or output object. After this I make a character type global variable starting 0 to 9. MAJOR PART OF PROGRAM DETAILS OF CODE
  • 3. 2.Main function: After this I declared 2 functions checkwin and board. After this the Main function is started Main logical and arithmetical steps occurred in this function. I declared variables and assign player variable to 1. I use do while loop in this program. First of all I call the board function to display the main structure of game. This function display the structure as : After this first player enters a number (1 to 9) and the control according to that number check the conditions that I made in the if else if structure . I use a variable choice that save the number of user. And mark variable
  • 4. assign player 1 X sign and 0 sign to second player. After the if else if structure I mention if the user enter wrong number not from 1 to 9 then computer display that the user enter invalid number. After this in each case main function call the checkwin function that check any player wins or not. If player is win then its display the result who is the winer with a beep . and if there is not, then the game will be continue. The result of checkwin function is save in the variable i and loop condition is running until condition becomes false.
  • 5. 3.Checkwin function: It is the function, used for detecting the winner or determining the drawn result. In this function all conditions are given. Any condition is true then this function return the result 1 and loop will be terminated and if the game draw the function return the result 0. Or the game will be continue this function return -1 and loop will not be terminated.
  • 6. 4.Board function: It is the function used for printing out playing board.
  • 8.
  • 9. SCREEN SHOTS OF PROGRAM: