08 March, 2013

C++ Program For Calculating Cricket Team Average.

This Post Contains A C++ Program For Calculating Cricket Team Average With Correct Source Code, Algorithm & Output. This Program Is Written, Compiled & Executed At TurboC/C++3.0 Compiler & Will Help You To Understand The Concept Of 'For-Loop' From C++ Language. It Is A Well-Structured Program With Proper Comments Which Provides Step-By-Step Description Of Various Features Of The Language In A Simple & Easy-To-Understand Way.


# Note : You Can Simply Copy-Paste The Following Program Or Code Into Compiler For Direct Result.



C++ Program For Calculating Cricket Team Average.

/* Declaration Of Header Files */
#include<iostream.h>
#include<conio.h>

/* Start Of Main Program */
void main()
{
  
   /* Declaration Of Variables */
   int p, no_ply, ing[10], run[10], avg[10];
   char name[10][10];

   clrscr();

  
   /* Asking For The Input From User */
   cout<<"\n Enter No. Of Players :";
   cin>>no_ply;
   for(p=0; p<no_ply; p++)
   {
      avg[p]=0;
      cout<<"\n Enter Player's Name :";
      cin>>name[p];
      cout<<"\n Enter Runs Scored :";
      cin>>run[p];
      cout<<"\n Enter No. Of Innings :";
      cin>>ing[p];
      avg[p]=run[p]/ing[p];
   }


   
   /* Printing The Output Onto The Screen/Console */
   for(p=0; p<no_ply; p++)
   {
      cout<<"\n Player's Name : "<<name[p];
      cout<<"\n Runs Scored : "<<run[p];
      cout<<"\n No. Of Innings : "<<ing[p];
      cout<<"\n Avg Runs : "<<avg[p];
   }

   getch();
}
/* End Of Main Program */


Output :

Enter No. Of Players : 2

Enter Player's Name : Saurav Ganguly
Enter Runs Scored : 234
No. Of Innings : 2

Enter Player's Name : Rahul Dravid
Enter Runs Scored : 345
No. Of Innings : 3

Enter Player's Name : Saurav Ganguly
Enter Runs Scored : 234
No. Of Innings : 2
Avg Runs : 117

Enter Player's Name : Rahul Dravid
Enter Runs Scored : 345
No. Of Innings : 3
Avg Runs : 115




No comments:

Post a Comment

Subscribe To:

Most Commonly Asked Programs In 'C' & 'C++' Language.