Add to Favorites    Make Home Page 2309 Online  
 Language Categories  
 Our Services  

Home » C Home » Beginners / Lab Assignments Home » x and zeros

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title x and zeros
Author chethan.b.e
Author Email chethankush [at] rediffmail.com
Description This is a game of two players.
Atleast of two players is required
Category C » Beginners / Lab Assignments
Hits 378047
Code Select and Copy the Code
Code : #include<stdio.h> #include<conio.h> #include<stdlib.h> #include<dos.h> #include<graphics.h> int x[10]={0},y[10]={0},z[10]={0},f=0; char a[10]={"player1"},b[10]={"player2"}; void intro() { gotoxy(15,14); printf("CHETHAN'S:VER 6.0A"); gotoxy(15,18); printf("THIS GAME IS X'S AND 0'S "); gotoxy(15,22); printf("IT TAKES ONLY FOUR ATTEMPTS OF URS "); gotoxy(15,25); printf("JUST ENTER THE POSITION VALUE AND THEN PRESS ENTER "); } void zero() { gotoxy(25,1); printf("%s won the game",b); f=1; } void xos() { gotoxy(25,1); printf("%s won the game",a); f=1; } void conclusion() { if((z[1]&z[2]&z[3])==3) zero(); else if((z[1]&z[5]&z[9])==3) zero(); else if((z[1]&z[4]&z[7])==3) zero(); else if((z[4]&z[5]&z[6])==3) zero(); else if((z[7]&z[8]&z[9])==3) zero(); else if((z[2]&z[5]&z[8])==3) zero(); else if((z[3]&z[6]&z[9])==3) zero(); else if((z[3]&z[5]&z[7])==3) zero(); else if((x[1]&x[2]&x[3])==2) xos(); else if((x[1]&x[5]&x[9])==2) xos(); else if((x[1]&x[4]&x[7])==2) xos(); else if((x[4]&x[5]&x[6])==2) xos(); else if((x[7]&x[8]&x[9])==2) xos(); else if((x[2]&x[5]&x[8])==2) xos(); else if((x[3]&x[6]&x[9])==2) xos(); else if((x[3]&x[5]&x[7])==2) xos(); } void position1(int x) { switch(x) { case 1:gotoxy(34,13); printf("X"); break; case 2:gotoxy(41,13); printf("X"); break; case 3:gotoxy(46,13); printf("X"); break; case 4:gotoxy(34,16); printf("X"); break; case 5:gotoxy(41,16); printf("X"); break; case 6:gotoxy(46,16); printf("X"); break; case 7:gotoxy(34,19); printf("X"); break; case 8:gotoxy(41,19); printf("X"); break; case 9:gotoxy(46,19); printf("X"); break; } } void position2(int y) { switch(y) { case 1:gotoxy(34,13); printf("0"); break; case 2:gotoxy(41,13); printf("0"); break; case 3:gotoxy(46,13); printf("0"); break; case 4:gotoxy(34,16); printf("0"); break; case 5:gotoxy(41,16); printf("0"); break; case 6:gotoxy(46,16); printf("0"); break; case 7:gotoxy(34,19); printf("0"); break; case 8:gotoxy(41,19); printf("0"); break; case 9:gotoxy(46,19); printf("0"); break; } } void start() { int gd=DETECT,gm; initgraph(&gd,&gm,"c:\tc\bgi"); } void first() { int i; scanf("%d",&i); if(y[i]==1) exit(0); y[i]=1; x[i]=2; sound(200); delay(400); nosound(); position1(i); } void second() { int i; scanf("%d",&i); if(y[i]==1) exit(1); y[i]=1; z[i]=3; sound(400); delay(400); nosound(); position2(i); } void body() { line(293,160,293,320); line(346,160,346,320); line(240,213,400,213); line(240,266,400,266); } void main() { start(); cleardevice(); rectangle(0,0,getmaxx(),getmaxy()); setbkcolor(0); intro(); getch(); cleardevice(); rectangle(0,0,getmaxx(),getmaxy()); setbkcolor(1); gotoxy(1,1); printf("please enter the player1 name:"); gets(a); cleardevice(); rectangle(0,0,getmaxx(),getmaxy()); gotoxy(1,1); printf("please enter the player2 name:"); gets(b); cleardevice(); body(); setbkcolor(1); rectangle(0,0,getmaxx(),getmaxy()); gotoxy(1,1); first(); gotoxy(1,1); second(); gotoxy(1,1); first(); gotoxy(1,1); second(); gotoxy(1,1); first(); conclusion(); gotoxy(1,1); if(f==0) { second(); conclusion(); gotoxy(1,1); if(f==0) { first(); conclusion(); gotoxy(1,1); if(f==0) { second(); conclusion(); } } } gotoxy(25,1); if(f==0) printf("game draw"); getch(); delay(10); cleardevice(); delay(10); closegraph(); getch(); }

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
RECURSIVE BALANCED QUICK SORT ashish
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi ¦Õ¤ ?¤Ð Ãß??ÝÐÝ
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=1034


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review