Cricket Score Sheet In C

  • void date can be used to store the current date or game date.
  • To print the result in the specified format, use the void printt method.
  • void filewrite is used to save input data such as runs, wickets, balls and overs to a file on the computer's hard disk.
  • void fileread is used to read or extract data from files that have been created to store data.
  • Opens the cricket score project file from the computer using the void fileopen(char) function.
  • limitedinput(int) - for entering a small amount of data.
  • Create a new scoresheet in a new file using the void newscoresheet method.

The cricket score sheet project file performs the following tasks when executed:

The welcome screen appears at the start of the project and fades up to reveal the main menu. On the main menu, there are three options:

  • Make a fresh score sheet.
  • Check out the previous score sheet.
  • Exit

Project Cricket Score Sheet will prompt for the name of the new score if the number '1' is entered. A notification will appear on the screen after the file is created. The user must then complete a scoring sheet which requires the following details:

  • Competition\Venue
  • Between and against the winning Toss team
  • Draw winner chosen
  • Date and shift
  • The name of each batsman and the runs scored by each
  • Each blower listing the pitcher's name and run

The software prompts the user to press "e" for editing data or "c" to proceed after inputting the necessary details. Upon selecting option "2" from the main menu, the user is prompted to enter the file name. If the file exists, its contents are shown; otherwise, an error message is displayed. The third choice in the main menu is to Exit. Inputting "3" in the main menu terminates the Cricket Score Sheet project.

Program Breakdown

Example

struct batsman
{
    char name [ 25 ] ;
    int runs , score , balls , toruns , tobal , ones , twos , threes , fours , sixes ;
    int max_six , max_run , max_four ;
    float str ;
}

Creating a structure for batsman.

Example

struct bowler
{
    char name [ 25 ] ;
    int runsgv , wkttkn , overs ;
    int max_w ;
    float econ ;
}

Creating a structure for bowler.

Example

int plno , choice ;
int i , n , m ;
printf ( " Enter the Batsman detail : \ n " ) ;
printf ( " Enter the number of batsman : \ n " ) ;
scanf ( " % d " , & m ) ;

Within the primary function of the software, the user will be prompted to input their selection.

Example

for ( i = 0 ; i < m ; i + + ) 
    {
        printf ( " Enter name of batsman % d : \ n " , i + 1 ) ;
        scanf ( " % s " , pl1 [ i ]. name ) ;
        printf ( " Enter the number of ones scored by player % d : \ n " , i + 1 ) ;
        scanf ( " % d " , & pl1 [ i ]. ones ) ;
        printf ( " Enter the number of twos scored by player % d : \ n " , i + 1 ) ;
        scanf ( " % d " , & pl1 [ i ]. twos ) ;
        printf ( " Enter the number of threes scored by player % d : \ n " , i + 1 ) ;
        scanf ( " % d " , & pl1 [ i ]. threes ) ;
        printf ( " Enter the number of fours scored by player % d : \ n " , i + 1 ) ;
        scanf ( " % d " , & pl1 [ i ]. fours ) ;
        printf ( " Enter the number of sixes scored by player % d : \ n " , i + 1 ) ;
        scanf ( " % d " , & pl1 [ i ]. sixes ) ;

        printf ( " Enter the balls played by the player % d : \ n " , i + 1 ) ;
        scanf ( " % d " , & pl1 [ i ]. balls ) ;
    }

The above code will manage the detailed scoring information of the batsman.

Example

for ( i = 0 ; i < n ; i + + )
    {

        printf ( " \ n Enter name of bowler % d : " , i + 1 ) ;
        scanf ( " % s " , pl2 [ i ]. name ) ;

        printf ( " Enter the runs given by the bowler % d : \ n " , i + 1 ) ;
        scanf ( " % d " , & pl2 [ i ]. runsgv ) ;

        printf ( " Enter the overs bowled by the bowler % d : \ n " , i + 1 ) ;
        scanf ( " % d " , & pl2 [ i ]. overs ) ;

        printf ( " Enter the wickets taken by the bowler % d \ n " , i + 1 ) ;
        scanf ( " % d " , & pl2 [ i ]. wkttkn ) ;
    }

Bowler details will be handle by above code.

Example

switch ( choice )
        {
        case 1 :
            printf ( " Enter the batsman number to see his details \ n " ) ;
            scanf ( " % d " , & plno ) ;

            plno - - ;
            printf ( " Player Detail \ n " ) ;
            printf ( " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ) ;
            printf ( " Batsman        runs           balls        fours       sixes         sr   \ n " ) ;
            printf ( " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n");
            pl1 [ plno ]. runs = ( 1 * pl1 [ plno ]. ones ) + ( 2 * pl1 [ plno ]. twos ) + (3 * pl1 [ plno ]. threes ) + ( 4 * pl1 [ plno ]. fours ) + ( 6 * pl1 [ plno ]. sixes ) ;
            pl1 [ plno ]. str = ( pl1 [ plno ]. runs * 100.00 ) / pl1 [ plno ]. balls ;
            printf ( " % - 15s % - 14d % - 13d % - 11d % - 11d % - 9.2f \ n \ n " , pl1 [ plno ]. name , pl1 [ plno ]. runs , pl1 [ plno ]. balls , pl1 [ plno ]. fours , pl1 [ plno ]. sixes , pl1 [ plno ]. str ) ;

If the user selects option 1 to input the batsman's information, the code mentioned above will be executed.

Example

case 2 :
            printf ( " Enter the bowlers number to see his details \ n " ) ;
            scanf ( " % d " , & plno ) ;

            plno - - ;
            printf ( " Player Detail \ n " ) ;
printf ( " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ) ;
            printf ( " Bowler        overs           runs        wicket       economy \ n " ) ;
            printf ( " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ) ;
            for ( i = 0 ; i < n ; i + + )
            {
                pl2 [ plno ]. econ = pl2 [ plno ]. runsgv / pl2 [ plno ]. overs ;
                printf ( " % - 15s % - 14d % - 13d % - 11d % - 11.2f \ n \ n " , pl2 [ plno ]. name , pl2 [ plno ]. overs , pl2 [ plno ]. runsgv , pl2 [ plno ]. wkttkn , pl2 [ plno ]. econ ) ;
            }
            break ;

If the user chooses option 2 to input the bowler's information, the code mentioned above will be executed.

Example

case 3 :
            printf ( "Match summary \ n " ) ;
            printf ( " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \  n " ) ;
            printf ( " Batsman        runs           balls        fours       sixes         sr   \ n " ) ;
            printf ( " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \n");
            for ( i = 0 ; i < 1 ; i + + )
            {
                pl1 [ i ]. runs = ( 1 * pl1 [ i ]. ones ) + ( 2 * pl1 [ i ]. twos ) + ( 3 * pl1 [ i ]. threes ) + ( 4 * pl1 [ i ]. fours ) + ( 6 * pl1 [ i ]. sixes ) ;
                pl3. toruns + = pl1 [ i ]. runs ;
                pl1 [ i ]. str = ( pl1 [ i ]. runs * 100. 00 ) / pl1 [ i ]. balls ;
                printf ( " % - 15s % - 14d % - 13d % - 11d % - 11d % - 9.2f \ n \ n " , pl1 [ i ]. name , pl1 [ i ]. runs , pl1 [ i ]. balls , pl1 [ i ]. fours , pl1 [ i ]. sixes , pl1 [ i ]. str ) ;
            }
            printf ( " TOTAL RUNS : % d \ n \ n " , pl3. toruns ) ;
            printf ( " \ n \ n " ) ;
            printf ( " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  = = = = = = = = =  = = = = = \ n " ) ;
            printf ( "  Bowler        overs           runs        wicket       economy \ n " ) ;
            printf ( " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n " ) ;
            for ( i = 0 ; i < n ; i + + )
            {
                pl2 [ i ]. econ = pl2 [ i ]. runsgv / pl2 [ i ]. overs ;
                printf ( " % - 15s % - 14d % - 13d % - 11d % - 11.2f \ n \ n \ n " , pl2 [ i ]. name , pl2 [ i ]. overs , pl2 [ i ]. runsgv , pl2 [ i ]. wkttkn , pl2 [ i ]. econ ) ;
            }

If a user chooses to view the match summary by selecting option 3, the code above will be executed.

Example

case 4 :
            pl3. max_run = 0 , pl4. max_w = 0 , pl3. max_four = 0 , pl3. max_six = 0 ;

            for ( i = 0 ; i < m ; i + + )
            {
                pl1 [ i ]. runs = ( 1 * pl1 [ i ]. ones ) + ( 2 * pl1 [ i ]. twos ) + ( 3 * pl1 [ i ]. threes ) + ( 4 * pl1 [ i ]. fours ) + ( 6 * pl1 [ i ]. sixes ) ;
                if ( pl3. max_run < pl1 [ i ]. runs )
                {
                    pl3. max_run = pl1 [ i ]. runs ;
                }

                if ( pl3. max_six < pl1 [ i ]. sixes )
                {
                    pl3. max_six = pl1 [ i ]. sixes ;
                }

                if ( pl3. max_four < pl1 [ i ]. fours )
                {
                    pl3. max_four = pl1 [ i ]. fours ;
                }

                if ( pl4. max_w < pl2 [ i ]. wkttkn )
                {
                    pl4. max_w = pl2 [ i ]. wkttkn ;
                }
            }
            printf ( " Highest runs scored by the batsman : % d \ n " , pl3. max_run ) ;

            printf ( " Maximum fours scored by the batsman : % d \ n " , pl3. max_four ) ;

            printf ( " Maximum sixes scored by the batsman % d : \ n " , pl3. max_six ) ;

            printf ( " Maximum wickets taken by the bowler : % d \ n " , pl4. max_w ) ;

            break ;

The preceding code snippet will display the top runs achieved by the batsman, the highest number of fours hit by the batsman, the maximum number of sixes scored by the batsman, and the most wickets taken by the bowler.

Example

case 5 :
            exit ( 1  ) ;
        default :
            printf ( " Enter the correct choice \ n " ) ;
            break ;
        }
    } while ( choice ! = 5 ) ;
    return 0 ;
}

If the user wishes to log out of the system, the code above will handle that action.

Program for Cricket Score Sheet in C

Example

#include <stdio.h>
#include <stdlib.h>
struct batsman
{
    char name[25];
    int runs, score, balls, toruns, tobal, ones, twos, threes, fours, sixes;
    int max_six, max_run, max_four;
    float str;
} pl1[100], pl3;
struct bowler
{
    char name[25];
    int runsgv, wkttkn, overs;
    int max_w;
    float econ;
} pl2[100], pl4;
int main()
{
    int plno, choice;
    int i, n, m;
    printf("Enter the Batsman detail:\n");
    printf("Enter the number of batsman:\n");
    scanf("%d", &m);
    for (i = 0; i < m; i++)
    {
        printf("Enter name of batsman%d:\n", i + 1);
        scanf("%s", pl1[i].name);
        printf("Enter the number of ones scored by player%d:\n ", i + 1);
        scanf("%d", &pl1[i].ones);
        printf("Enter the number of twos scored by player%d:\n ", i + 1);
        scanf("%d", &pl1[i].twos);
        printf("Enter the number of threes scored by player%d:\n ", i + 1);
        scanf("%d", &pl1[i].threes);
        printf("Enter the number of fours scored by player%d:\n ", i + 1);
        scanf("%d", &pl1[i].fours);
        printf("Enter the number of sixes scored by player%d:\n ", i + 1);
        scanf("%d", &pl1[i].sixes);

        printf("Enter the balls played by the player%d:\n", i + 1);
        scanf("%d", &pl1[i].balls);
    }

    printf("\nEnter the bowlers details:\n");

    printf("Enter the number of bowlers:\n");

    scanf("%d", &n);

    for (i = 0; i < n; i++)
    {

        printf("\nEnter name of bowler%d:", i + 1);
        scanf("%s", pl2[i].name);

        printf("Enter the runs given by the bowler%d:\n ", i + 1);
        scanf("%d", &pl2[i].runsgv);

        printf("Enter the overs bowled by the bowler%d:\n", i + 1);
        scanf("%d", &pl2[i].overs);

        printf("Enter the wickets taken by the bowler%d\n", i + 1);
        scanf("%d", &pl2[i].wkttkn);
    }

    printf("Thank you all details are recorded\n");

    do
    {

        printf("Enter the choice:\n 1)Batsman detail:\n 2)Bowlers detail:\n 3)Match summary:\n 4)Record:\n 5)Exit\n ");
        scanf("%d", &choice);

        switch (choice)
        {
        case 1:
            printf("Enter the batsman number to see his details\n");
            scanf("%d", &plno);

            plno--;
            printf("                       Player Detail\n");
            printf("= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n");
            printf(" Batsman        runs           balls        fours       sixes         sr   \n");
            printf("= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n");
            pl1[plno].runs = (1 * pl1[plno].ones) + (2 * pl1[plno].twos) + (3 * pl1[plno].threes) + (4 * pl1[plno].fours) + (6 * pl1[plno].sixes);
            pl1[plno].str = (pl1[plno].runs * 100.00) / pl1[plno].balls;
            printf(" %-15s %-14d %-13d %-11d %-11d %-9.2f\n\n", pl1[plno].name, pl1[plno].runs, pl1[plno].balls, pl1[plno].fours, pl1[plno].sixes, pl1[plno].str);

            break;

        case 2:
            printf("Enter the bowlers number to see his details\n");
            scanf("%d", &plno);

            plno--;
            printf("                         Player Detail\n  ");
printf(" = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \n");
            printf(" Bowler        overs           runs        wicket       economy\n");
            printf(" = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \n");
            for (i = 0; i < n; i++)
            {
                pl2[plno].econ = pl2[plno].runsgv / pl2[plno].overs;
                printf(" %-15s %-14d %-13d %-11d %-11.2f\n\n", pl2[plno].name, pl2[plno].overs, pl2[plno].runsgv, pl2[plno].wkttkn, pl2[plno].econ);
            }

            break;

        case 3:
            printf("                     Match summary\n");
            printf(" = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \n");
            printf(" Batsman        runs           balls        fours       sixes         sr   \n");
            printf(" = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \n");
            for (i = 0; i < 1; i++)
            {
                pl1[i].runs = (1 * pl1[i].ones) + (2 * pl1[i].twos) + (3 * pl1[i].threes) + (4 * pl1[i].fours) + (6 * pl1[i].sixes);
                pl3.toruns += pl1[i].runs;
                pl1[i].str = (pl1[i].runs * 100.00) / pl1[i].balls;
                printf(" %-15s %-14d %-13d %-11d %-11d %-9.2f\n\n", pl1[i].name, pl1[i].runs, pl1[i].balls, pl1[i].fours, pl1[i].sixes, pl1[i].str);
            }
            printf("TOTAL RUNS:%d\n\n", pl3.toruns);
            printf("\n\n");
            printf("= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  = = = = = = = = =  = = = = = \n");
            printf(" Bowler        overs           runs        wicket       economy\n");
            printf(" = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =\n");
            for (i = 0; i < n; i++)
            {
                pl2[i].econ = pl2[i].runsgv / pl2[i].overs;
                printf(" %-15s %-14d %-13d %-11d %-11.2f\n\n\n", pl2[i].name, pl2[i].overs, pl2[i].runsgv, pl2[i].wkttkn, pl2[i].econ);
            }

            break;

        case 4:
            pl3.max_run = 0, pl4.max_w = 0, pl3.max_four = 0, pl3.max_six = 0;

            for (i = 0; i < m; i++)
            {
                pl1[i].runs = (1 * pl1[i].ones) + (2 * pl1[i].twos) + (3 * pl1[i].threes) + (4 * pl1[i].fours) + (6 * pl1[i].sixes);
                if (pl3.max_run < pl1[i].runs)
                {
                    pl3.max_run = pl1[i].runs;
                }

                if (pl3.max_six < pl1[i].sixes)
                {
                    pl3.max_six = pl1[i].sixes;
                }

                if (pl3.max_four < pl1[i].fours)
                {
                    pl3.max_four = pl1[i].fours;
                }

                if (pl4.max_w < pl2[i].wkttkn)
                {
                    pl4.max_w = pl2[i].wkttkn;
                }
            }
            printf("Highest runs scored by the batsman:%d\n", pl3.max_run);

            printf("Maximum fours scored by the batsman:%d\n", pl3.max_four);

            printf("Maximum sixes scored by the batsman%d:\n", pl3.max_six);

            printf("Maximum wickets taken by the bowler:%d\n", pl4.max_w);

            break;

        case 5:
            exit(1);

        default:
            printf("Enter the correct choice\n");
            break;
        }

    } while (choice != 5);

    return 0;
}

Output:

Output

Enter the Batsman detail:
Enter the number of batsman:
 4
Enter name of batsman1:
Rohit
Enter the number of ones scored by player1:
 1
Enter the number of twos scored by player1:
 2
Enter the number of threes scored by player1:
 3
Enter the number of fours scored by player1:
 4
Enter the number of sixes scored by player1:
 6
Enter the balls played by the player1:
50
Enter name of batsman2:
Virat
Enter the number of ones scored by player2:
 1
Enter the number of twos scored by player2:
 4
Enter the number of threes scored by player2:
 2
Enter the number of fours scored by player2:
 2
Enter the number of sixes scored by player2:
 1
Enter the balls played by the player2:
33
Enter name of batsman3:
Hardik
Enter the number of ones scored by player3:
 4
Enter the number of twos scored by player3:
 1
Enter the number of threes scored by player3:
 1
Enter the number of fours scored by player3:
 1
Enter the number of sixes scored by player3:
 1
Enter the balls played by the player3:
35
Enter name of batsman4:
Shikhar
Enter the number of ones scored by player4:
 1
Enter the number of twos scored by player4:
 4
Enter the number of threes scored by player4:
 2
Enter the number of fours scored by player4:
 2
Enter the number of sixes scored by player4:
 2
Enter the balls played by the player4:
24

Enter the bowlers details:
Enter the number of bowlers:
2

Enter name of bowler1:Kunal
Enter the runs given by the bowler1:
 23
Enter the overs bowled by the bowler1:
3
Enter the wickets taken by the bowler1
0

Enter name of bowler2:Jadeja
Enter the runs given by the bowler2:
 43
Enter the overs bowled by the bowler2:
20
Enter the wickets taken by the bowler2
0
Thank you all details are recorded
Enter the choice:
 1)Batsman detail:
 2)Bowlers detail:
 3)Match summary:
 4)Record:
 5)Exit
Enter the batsman number to see his details
1
                       

                                                           Player Detail
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 Batsman        runs           balls        fours       sixes         sr
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 Rohit           66             50            4           6           132.00
Enter the choice:
 1)Batsman detail:
 2)Bowlers detail:
 3)Match summary:
 4)Record:
 5)Exit
Enter the batsman number to see his details
2
                       Player Detail
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 Batsman        runs           balls        fours       sixes         sr
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 Virat           29             33            2           1           87.88
Enter the choice:
 1)Batsman detail:
 2)Bowlers detail:
 3)Match summary:
 4)Record:
 5)Exit
                    Match summary
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 Batsman        runs           balls        fours       sixes         sr
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 Rohit           66             50            4           6           132.00

TOTAL RUNS:66
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 Bowler        overs           runs        wicket       economy
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 Kunal           3              23            0           7.00
 Jadeja          20             43            0           2.00
Highest runs scored by the batsman:66
Maximum fours scored by the batsman:4
Maximum sixes scored by the batsman6:
Maximum wickets taken by the bowler:0
Enter the choice:
 1)Batsman detail:
 2)Bowlers detail:
 3)Match summary:
 4)Record:
 5)Exit

Input Required

This code uses input(). Please provide values below: