You are on page 1of 11

NAME: ISWARJOT

SINGH
CLASS: XII A
ROLL NO. : 24

COMPUTER SCIENCE
PROJECT FILE
ODD EVEN

CERTIFICATE
This is to certify that the project named
ODDEVEN has been made by Ishwarjot
Singh of Class XII-A of Guru Tegh
Bahadur 3rd Centenary School as a part of
their curriculum for subject Computer
Science.

Teachers Signature

ACKNOWLEDGEMENT
In performing this assignment, I had to take
the help and guideline of some respected
persons, who deserve my greatest gratitude.
The completion of this assignment gives me
much Pleasure. I would like to show my
gratitude Mr. Ashish Kunwar, Course
Instructor of Computer Science, Guru Tegh
Bahadur 3rd Centenary School who introduced
me to the Methodology of work, and whose
passion for the underlying structures had
lasting effect & for giving me a good guideline
for assignment throughout numerous
consultations. I would also like to expand my
deepest gratitude to all those who have
directly and indirectly guided me in writing this
assignment.
Many people, especially my classmates, have
made valuable comment suggestions on this
proposal which gave me an inspiration to
improve my assignment. I thank all the people

for their help directly and indirectly to


complete my assignment.

About The
Project
The programme odd even is based on the
principles of the game ODD-EVEN also known
as finger cricket in which 2 people use their
hands to show gestures of nos. from 1 to 6. In
this one of them is bowler and the other one is
batsman in which both the player simultaneously
show their gestures and if the no. Represented
by their gesture is same then the batsman is
out otherwise it continues till their gestures
are same. The gesture represented by the
batsman is the no. of runs scored by him and till
the time he is out the total runs are the sums
of the numbers represented by his gestures.

Similarly once the player 1 is out player 2 is now


the batsman and player 1 the bowler. The player
whose no. of runs is more at the end is the
winner of the game.

Program
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
struct cric{
int runs;
char name[20];
}s[10];
void main()
{
char ch1;
int pos,n,ch,num,bowl,flag=0;
void randomize();
randomize;
do{
a:
clrscr();
cout<<setw(55)<<"=================
==============\n";

cout<<setw(55)<<"
Odd Even
\n";
cout<<setw(55)<<"=================
==============\n";
cout<<"\nPress 1 to Play\nPress 2 to view
Instructions\nPress 3 to Exit\n";
cin>>ch;
switch(ch)
{
case 1:clrscr();
cout<<"Enter the number of players\n";
cin>>n;
for(int i=0;i<n;i++)
{
cout<<"Enter the name of Player
"<<i+1<<":-\n";
cin>>s[i].name;
flag=0;
s[i].runs=0;
cout<<"Let's Start\n";
cout<<"Enter your number(1-6)";
cout<<setw(20)<<"CPU's Number\n";
do{
cin>>num;
bowl=random(6)+1;
cout<<setw(40)<<bowl<<endl;
cout<<"_________________________________________
__________________\n";
if(num>6)
{
cout<<"You entered an invalid number.You are
OUT!!!";
cout<<"\nYou scored "<<s[i].runs<<" runs\n";

flag=1;
}
else if(num!=bowl)
s[i].runs+=num;
else if(num==bowl)
{
cout<<"You are OUT!!!";
cout<<"\nYou scored "<<s[i].runs<<" runs.\n";
flag=1;
break;
}
}while(flag==0);
}
break;
case 2:cout<<"Instructions:-\n";
cout<<"1.The Player is required to select a
number between 1-6.\n2.If the number
generated by the computer is same as the
number chosen by the person, then the
person is out.\n3.If the two numbers are
different, the number chosen by the user
gets added to the user's total.\n4.If you
enter an invalid number, you will be
declared OUT.\n";
getch();
goto a;
case 3:goto b;
default:cout<<"Invalid choice";
getch();
goto a;
}
int max=s[0].runs;
for(int i=1;i<n;i++)

{
if(s[i].runs>max)
{
max=s[i].runs;
pos=i;
}
}
cout<<setw(50)<<"------------------------------\n";
cout<<setw(50)<<"
Scorecard
\n";
cout<<setw(50)<<"------------------------------\n";
for(int j=0;j<n;j++)
{
cout<<s[j].name<<"\t\t"<<s[j].runs<<"\n";
}
cout<<"\n\nThe Winner is "<<s[pos].name;
cout<<"\n\nDo you want to play again?(y/n)";
cin>>ch1;
}while(ch1=='y');
b:
clrscr();
gotoxy(31,10);
cout<<"Created By:-\n\n";
cout<<setw(45)<<"Ishwarjot Singh\n";
getch();
}

Output

You might also like