SlideShare a Scribd company logo
WELCOME
TIK TOK TOY (XOXO)
 Badhon Kumar Biswas
 Green University Of Bangladesh
 ID: 183001005
 Dept: EEE
CODE :
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<windows.h>
int board[10]={2,2,2,2,2,2,2,2,2,2};
int turn=1, flag=0;
int player, comp;
int menu();
int go (int n);
int start_game();
int check_draw();
int draw_board();
int player_first();
int put_X_O(char ch,int pos);
COORD coord={0,0};
int gotoxy(int x , int y)
{
coord.X=x;
coord. Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
int main()
{
system("cls");
menu();
getch();
}
int menu()
{
int choice;
system("cls");
printf("n-----Menu-----");
printf("n1 : Play with X");
printf("n2 : Play with O");
printf("n3 : Exit");
printf("n4 : Enter Your Choice: ");
scanf("%d",&choice);
turn=1;
switch(choice)
{
case 1:
player = 1;
comp=0;
player_first();
break;
case 2:
player = 0;
comp = 1;
start_game();
break;
case 3:
exit(1);
default:
menu();
}
}
int make2()
{
if(board[5]==2)
return 5;
if(board[2]==2)
return 2;
Case 2
Case 1
if(board[4]==2)
return 4;
if(board[8]==2)
return 8;
return 0;
}
int make4()
{
if(board[1]==2)
return 1;
if(board[3]==2)
return 3;
if(board[7]==2)
return 7;
if(board[9]==2)
return 9;
return 0;
}
int posswin(int p)
{
int i;
int check_val,pos;
if(p==1)
check_val=18;
else
check_val= 50;
i = 1;
while(i<=9)
{
if(board[i] * board[i+1] * board[i+2]==check_val)
{
if(board[i]==2)
return i;
if(board[i+1]==2)
return i+1;
if(board[i+2]==2)
return i+2;
}
i+=3;
}
i = 1;
while(i<=3)
{
if(board[i]* board[i+3]* board[i+6] == check_val)
if(board[1] * board[i+5] * board[i+7]==check_val)
{
if(board[3]==2)
return 3;
if(board[i+5]==2)
return i+5;
if(board[i+7]==2)
return i+7;
}
return 0;
}
i n t g o ( i n t n )
{
i f ( t u r n % 2 )
b o a r d [ n ] = 3 ;
e l s e
b o a r d [ n ] = 5 ;
t u r n + + ;
}
i n t p l a y e r _ f i r s t ( )
{
i n t p o s ;
c h e c k _ d r a w ( ) ;
d r a w _ b o a r d ( ) ;
g o t o x y ( 3 0 , 1 8 ) ;
p r i n t f ( " Yo u r Tu r n : > " ) ;
s c a n f ( " % d " , & p o s ) ;
i f ( b o a r d [ p o s ] ! = 2 )
p l a y e r _ f i r s t ( ) ;
i f ( p o s = = p o s s w i n ( p l a y e r ) )
{
g o ( p o s ) ;
d r a w _ b o a r d ( ) ;
g o t o x y ( 3 0 , 2 0 ) ;
p r i n t f ( " P l a y e r W i n s " ) ;
g e t c h ( ) ;
e x i t ( 0 ) ;
}
g o ( p o s ) ;
d r a w _ b o a r d ( ) ;
s t a r t _ g a m e ( ) ;
}
i n t s t a r t _ g a m e ( )
{
i f ( p o s s w i n ( c o m p ) )
{
g o ( p o s s w i n ( c o m p ) ) ;
f l a g = 1 ;
}
e l s e i f ( p o s s w i n ( p l a y e r ) )
g o ( p o s s w i n ( p l a y e r ) ) ;
e l s e i f ( m a k e 2 ( ) )
g o ( m a k e 2 ( ) ) ;
e l s e
g o ( m a k e 4 ( ) ) ;
d r a w _ b o a r d ( ) ;
if(flag)
{
gotoxy(30,20);
printf("Computer Wins");
getch();
}
else
player_first();
}
int check_draw()
{
if(turn>9)
{
gotoxy(30,20);
printf("Game Draw");
getch();
exit(0);
}
}
int draw_board()
{
int j;
for(j=9; j<17; j++)
{
gotoxy(35,j);
printf("| |");
}
gotoxy(28,11);
printf("_____________________");
gotoxy(28,14);
printf("_____________________");
for(j=1; j<10; j++)
{
if(board[j]==3)
put_X_O('X',j);
else if(board[j]==5)
put_X_O('O',j);
}
}
int put_X_O(char ch , int pos)
{
int m;
int x = 31, y = 10;
m = pos;
if(m>3)
{
while(m>3)
{
y+=3;
m-=3;
}
}
if(pos%3==0)
x+=16;
else
{
pos%=3;
pos--;
while(pos)
{
x+=8;
pos--;
}
}
gotoxy(x,y);
printf("%c",ch);
}
 OUTPUT :
THANK YOU


More Related Content

PPTX
Master Thesis presentation
DOCX
HOTEL MANGEMENT
PDF
Linux tips
DOCX
Komputer Grafik
DOCX
KEY
Blocks+gcd入門
Master Thesis presentation
HOTEL MANGEMENT
Linux tips
Komputer Grafik
Blocks+gcd入門

What's hot (17)

PDF
Hashing enderecamento aberto bean - bean
DOCX
Circular queue
PPTX
JavaScript Gotchas
DOC
Find the output of the following code (Java for ICSE)
PDF
Diploma - French Diploma
DOCX
Programa en C++ ( escriba 3 números y diga cual es el mayor))
PDF
PPTX
3. chapter ii
PPTX
ภาษาซี
PPTX
ภาษาซี
PPTX
Double linked list
PPTX
Session05 iteration structure
PPTX
4. chapter iii
PPTX
Double linked list
PPT
C questions
Hashing enderecamento aberto bean - bean
Circular queue
JavaScript Gotchas
Find the output of the following code (Java for ICSE)
Diploma - French Diploma
Programa en C++ ( escriba 3 números y diga cual es el mayor))
3. chapter ii
ภาษาซี
ภาษาซี
Double linked list
Session05 iteration structure
4. chapter iii
Double linked list
C questions
Ad

Similar to Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming (20)

DOCX
#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx
PDF
The following is my code for a connectn program. When I run my code .pdf
DOC
C++ projct
 
PDF
COnnect4Game
TXT
Tic tac toe
PDF
Please follow the data 1) For Line 23 In the IF - Condition yo.pdf
PPTX
PDF
Connect4.c2. Include the string.h header file3. Declare the foll.pdf
PDF
I have to write a Connect Four game program When a player t.pdf
PDF
AI CHALLENGE ADMIN
PPT
Tic tac toe c++ programing
PDF
#In this project you will write a program play TicTacToe #using tw.pdf
PDF
#In this project you will write a program play TicTacToe #using tw.pdf
PPTX
python.pptx
PDF
Please help with this. program must be written in C# .. All of the g.pdf
PPT
Tic tac toe on c++ project
PDF
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
DOCX
Artificial intelligence - python
DOCX
Tik tic tok
#include -stdio-h- #include -stdlib-h- #include -stdbool-h- #include - (1).docx
The following is my code for a connectn program. When I run my code .pdf
C++ projct
 
COnnect4Game
Tic tac toe
Please follow the data 1) For Line 23 In the IF - Condition yo.pdf
Connect4.c2. Include the string.h header file3. Declare the foll.pdf
I have to write a Connect Four game program When a player t.pdf
AI CHALLENGE ADMIN
Tic tac toe c++ programing
#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
python.pptx
Please help with this. program must be written in C# .. All of the g.pdf
Tic tac toe on c++ project
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
Artificial intelligence - python
Tik tic tok
Ad

Recently uploaded (20)

PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
master seminar digital applications in india
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Classroom Observation Tools for Teachers
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
RMMM.pdf make it easy to upload and study
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Institutional Correction lecture only . . .
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Computing-Curriculum for Schools in Ghana
PDF
Supply Chain Operations Speaking Notes -ICLT Program
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Module 4: Burden of Disease Tutorial Slides S2 2025
Final Presentation General Medicine 03-08-2024.pptx
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
master seminar digital applications in india
Chinmaya Tiranga quiz Grand Finale.pdf
01-Introduction-to-Information-Management.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Classroom Observation Tools for Teachers
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
RMMM.pdf make it easy to upload and study
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Institutional Correction lecture only . . .
102 student loan defaulters named and shamed – Is someone you know on the list?
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Computing-Curriculum for Schools in Ghana
Supply Chain Operations Speaking Notes -ICLT Program

Real Life Uses of a Program (Tik Tok Toy Game) useing by C Programming