"The best way to cheer yourself up is to try to cheer somebody else up." Mark Twain

Monday, January 18, 2010

Write a program to record score of a cricket match. One array stores information of batting team such as bat'sman name, runs scored, indication if out, mode by which out along with total runs, overs played, total overs and extras. The other array stores information about bowling team such as bowler's name, over's bowled, maiden overs, runs given, and wicked taken. The program reads in the above information and depending upon the user's choice, it displays either the batting team's information or the bowling team's information.


#include<iostream.h>
#include<conio.h>
#include<stdio.h>




struct batting
{
char batsman[20];
int run;
boolean out;
int tot_run;
int overs;
int total_over;
int extra;
};




struct bowling
{
char bowler[20];
int overs;
int maiden_overs;
int runs;
int wicket;
};


void main()
{
batting bat_team[12];


bowling bo_team[12];


cout<<"\n Enter records of batting team :\n\n";
for(int i = o; i < 12 ; i++)
{
cout<<"\n Enter bat's man name :";
gets(bat_team[i].batsman);
cout<<"\n Enter run scored :";
cin>>bat_team[i].run;
cout<<"\n Type 0 NOT-OUT , Type 1 if OUT :";
cin>>bat_team[i].out;
cout<<"\n Enter total run :";
cin>>bat_team[i].total_run;
cout<<"\n Enter no. of overs played :";
cin>>bat_team[i].overs;
cout<<"\n Enter total over:";
cin>>bat_team[i].total_over;
cout<<"\n Extra ?";
cin>>bat_team[i].extra;
}


cout<<"\n Enter records of bowling team :\n\n";


for( i = o; i < 12 ; i++)
{
cout<<"\n Enter bowler's name :";
gets(bo_team[i].bowler);
cout<<"\n Enter overs bowled :";
cin>>bo_team[i].overs;
cout<<"\n Enter maiden overs :";
cin>>bo_team[i].maiden_overs;
cout<<"\n Enter runs :";
cin>>bo_team[i].runs;
cout<<"\n Enter wicked taken:";
cin>>bo_team[i].wicket;
}






char ch;
int n;


do
{
clrscr();


cout<<"\n Enter 1 to view batting team information:";


cout<<"\n Enter 2 to view bowling team information:";


cout<<"\n Enter your choice :";


cin>>n;


switch(n)


{


case 1:


cout<<"\n ************* BATTING TEAM *************\n";


cout<<"\n Name \t RUN-Scored Out Total-run Over's-played Total-Overs Extra ";


for( i = o; i < 12 ; i++)


{


cout<<"\n"<< bat_team[i].batsman <<"\t"<< bat_team[i].run<<" ";


if(bat_team.out)


cout<<"OUT";
else
cout<<"NOT-OUT";


cout<< " " <<   bat_team[i].total_run<< " " << bat_team[i].overs << " " << bat_team[i].total_over<<  " "<< bat_team[i].extra;
}


break;




case 2:


cout<< "\n ************* BOWLING TEAM *************\n";
cout<< "\n Name \t Overs_bowled Maiden-Overs Runs-Given Wicket-Taken ";


for( i = o; i < 12 ; i++)


{
cout<<  "\n"<< bo_team[i].bowler<< "\t"<< bo_team[i].overs<< " ";
cout<< " "<< bo_team[i].maiden_overs<< " "<< bo_team[i].runs<< " "<< bo_team[i].wicket<<" ";
}
break;


default:




cout<< "\n Wrong choice.";
 
}
 
cout<<"\n Do you continue (y/n);


cin>>ch;


}while(ch=='y' | | ch == 'Y');
getch();
}

1 comment:

  1. should'nt we include mode of out and which bowler took whose wicket???

    ReplyDelete

C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.
Now Playing: Ballade Pour Adeline

About Me

My photo
I m an IT lecturer of a college. I love social-work. I want to do something beneficial for society before dying , that can promote our society, to some extent.