Saturday, 14 March 2015

Calculate The Statistics Of Players in C Solution

/*   Since 2001, Bangladesh captain Mashrafe Mortaza has been a staple of Bangladesh’s pace attack. The BCC (Bangladesh Cricket Council) wants to compute certain statistics about him which are:
AVE (Bowling average: The average number of runs conceded per wicket) ECON (Economy rate: The average number of runs conceded per over) SR (Strike rate: The average number of balls bowled per wicket taken) Now, write a C program which can help BCC to calculate the statistics of players like Mashrafe. You need to take appropriate input from user to compute AVE, ECON & SR. */


    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
int main(){

    int NumOfBallsBowled,NumOfRunsConceded,NumOfWickTaken;
    float BowlingAverage,EconomyRate,StrikeRate;

    /*User input*/
    printf("Number of balls bowled: ");
    printf("Number of runs conceded: ");
    printf("Number of wickets taken: ");

    /*Calculating Average*/
    BowlingAverage = (float)(NumOfRunsConceded/NumOfWickTaken);
    EconomyRate = (float)((NumOfRunsConceded)/(NumOfBallsBowled/6));//here Type casting(float) converting a variable from one data type to
    StrikeRate = (float)(NumOfBallsBowled/NumOfWickTaken);          // another data type.

    /*Printing Calculated value*/
    printf("\nBowling Average: %.2f\n",BowlingAverage);
    printf("Economy Rate: %.2f\n",EconomyRate);//If you want the output to contain a different number of
    printf("Strike Rate: %.2f\n",StrikeRate);  //decmal places then you must put a decimal point between % and f
    return 0;

No comments:

Post a Comment