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

What's hot

Hashing enderecamento aberto bean - bean
Hashing enderecamento aberto bean - beanHashing enderecamento aberto bean - bean
Hashing enderecamento aberto bean - bean
Elaine Cecília Gatto
 
Circular queue
Circular queueCircular queue
Circular queue
ShobhaHiremath8
 
JavaScript Gotchas
JavaScript GotchasJavaScript Gotchas
JavaScript Gotchas
Robert MacLean
 
Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)
Mokshya Priyadarshee
 
Diploma - French Diploma
Diploma - French DiplomaDiploma - French Diploma
Diploma - French DiplomaIlham Aminuddin
 
Programa en C++ ( escriba 3 números y diga cual es el mayor))
Programa en C++ ( escriba 3 números y diga cual es el mayor))Programa en C++ ( escriba 3 números y diga cual es el mayor))
Programa en C++ ( escriba 3 números y diga cual es el mayor))Alex Penso Romero
 
BCSL 058 solved assignment
BCSL 058 solved assignmentBCSL 058 solved assignment
3. chapter ii
3. chapter ii3. chapter ii
3. chapter ii
Chhom Karath
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซีkramsri
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซีkramsri
 
Wca
WcaWca
Double linked list
Double linked listDouble linked list
Double linked list
Sayantan Sur
 
Session05 iteration structure
Session05 iteration structureSession05 iteration structure
Session05 iteration structure
HarithaRanasinghe
 
4. chapter iii
4. chapter iii4. chapter iii
4. chapter iii
Chhom Karath
 
Double linked list
Double linked listDouble linked list
Double linked list
raviahuja11
 
C questions
C questionsC questions
C questions
mohamed sikander
 

What's hot (17)

Hashing enderecamento aberto bean - bean
Hashing enderecamento aberto bean - beanHashing enderecamento aberto bean - bean
Hashing enderecamento aberto bean - bean
 
Circular queue
Circular queueCircular queue
Circular queue
 
JavaScript Gotchas
JavaScript GotchasJavaScript Gotchas
JavaScript Gotchas
 
Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)Find the output of the following code (Java for ICSE)
Find the output of the following code (Java for ICSE)
 
Diploma - French Diploma
Diploma - French DiplomaDiploma - French Diploma
Diploma - French Diploma
 
Programa en C++ ( escriba 3 números y diga cual es el mayor))
Programa en C++ ( escriba 3 números y diga cual es el mayor))Programa en C++ ( escriba 3 números y diga cual es el mayor))
Programa en C++ ( escriba 3 números y diga cual es el mayor))
 
Avl tree
Avl treeAvl tree
Avl tree
 
BCSL 058 solved assignment
BCSL 058 solved assignmentBCSL 058 solved assignment
BCSL 058 solved assignment
 
3. chapter ii
3. chapter ii3. chapter ii
3. chapter ii
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
 
Wca
WcaWca
Wca
 
Double linked list
Double linked listDouble linked list
Double linked list
 
Session05 iteration structure
Session05 iteration structureSession05 iteration structure
Session05 iteration structure
 
4. chapter iii
4. chapter iii4. chapter iii
4. chapter iii
 
Double linked list
Double linked listDouble linked list
Double linked list
 
C questions
C questionsC questions
C questions
 

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

    #include STDIO.H     int main() {        char file_name[.pdf
    #include STDIO.H     int main() {        char file_name[.pdf    #include STDIO.H     int main() {        char file_name[.pdf
    #include STDIO.H     int main() {        char file_name[.pdf
anjalipub
 
Bai Giang 11
Bai Giang 11Bai Giang 11
Bai Giang 11nbb3i
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
Kandarp Tiwari
 
Prelude to halide_public
Prelude to halide_publicPrelude to halide_public
Prelude to halide_public
Fixstars Corporation
 
Network lap pgms 7th semester
Network lap pgms 7th semesterNetwork lap pgms 7th semester
Network lap pgms 7th semesterDOSONKA Group
 
Computer graphics File for Engineers
Computer graphics File for EngineersComputer graphics File for Engineers
Computer graphics File for Engineers
varun arora
 
Ejercicios de programacion
Ejercicios de programacionEjercicios de programacion
Ejercicios de programacionJeff Tu Pechito
 
Graphics programs
Graphics programsGraphics programs
Graphics programs
NAVYA RAO
 
Flow of events during Media Player creation in Android
Flow of events during Media Player creation in AndroidFlow of events during Media Player creation in Android
Flow of events during Media Player creation in Android
Somenath Mukhopadhyay
 
Cpds lab
Cpds labCpds lab
Snake.c
Snake.cSnake.c
Snake.c
Vijay Singh
 
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
asif1401
 
C Programming :- An Example
C Programming :- An Example C Programming :- An Example
C Programming :- An Example
Atit Gaonkar
 
Cpd lecture im 207
Cpd lecture im 207Cpd lecture im 207
Cpd lecture im 207
Syed Tanveer
 
Code GPU with CUDA - Applying optimization techniques
Code GPU with CUDA - Applying optimization techniquesCode GPU with CUDA - Applying optimization techniques
Code GPU with CUDA - Applying optimization techniques
Marina Kolpakova
 
Arrays in c
Arrays in cArrays in c
C Prog - Pointers
C Prog - PointersC Prog - Pointers
C Prog - Pointersvinay arora
 

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

    #include STDIO.H     int main() {        char file_name[.pdf
    #include STDIO.H     int main() {        char file_name[.pdf    #include STDIO.H     int main() {        char file_name[.pdf
    #include STDIO.H     int main() {        char file_name[.pdf
 
Bai Giang 11
Bai Giang 11Bai Giang 11
Bai Giang 11
 
Computer Graphics Lab File C Programs
Computer Graphics Lab File C ProgramsComputer Graphics Lab File C Programs
Computer Graphics Lab File C Programs
 
Prelude to halide_public
Prelude to halide_publicPrelude to halide_public
Prelude to halide_public
 
Network lap pgms 7th semester
Network lap pgms 7th semesterNetwork lap pgms 7th semester
Network lap pgms 7th semester
 
efy-articles
efy-articlesefy-articles
efy-articles
 
programs
programsprograms
programs
 
Computer graphics File for Engineers
Computer graphics File for EngineersComputer graphics File for Engineers
Computer graphics File for Engineers
 
Ejercicios de programacion
Ejercicios de programacionEjercicios de programacion
Ejercicios de programacion
 
Graphics programs
Graphics programsGraphics programs
Graphics programs
 
Flow of events during Media Player creation in Android
Flow of events during Media Player creation in AndroidFlow of events during Media Player creation in Android
Flow of events during Media Player creation in Android
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
Snake.c
Snake.cSnake.c
Snake.c
 
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
 
C Programming :- An Example
C Programming :- An Example C Programming :- An Example
C Programming :- An Example
 
Cpd lecture im 207
Cpd lecture im 207Cpd lecture im 207
Cpd lecture im 207
 
Code GPU with CUDA - Applying optimization techniques
Code GPU with CUDA - Applying optimization techniquesCode GPU with CUDA - Applying optimization techniques
Code GPU with CUDA - Applying optimization techniques
 
Vcs17
Vcs17Vcs17
Vcs17
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
C Prog - Pointers
C Prog - PointersC Prog - Pointers
C Prog - Pointers
 

Recently uploaded

Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 

Recently uploaded (20)

Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 

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