0% found this document useful (0 votes)
10 views

Experiment No 13

The document outlines an experiment to write a C program that utilizes structures to store information about cricketers, including their names, matches played, runs scored, and strike rates. It includes objectives, theory on structures and unions, a step-by-step procedure for writing and executing the program, and a code example. The conclusion highlights the successful execution of the experiment and the understanding of structure members.

Uploaded by

anniisaniket
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Experiment No 13

The document outlines an experiment to write a C program that utilizes structures to store information about cricketers, including their names, matches played, runs scored, and strike rates. It includes objectives, theory on structures and unions, a step-by-step procedure for writing and executing the program, and a code example. The conclusion highlights the successful execution of the experiment and the understanding of structure members.

Uploaded by

anniisaniket
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Experiment No.

13
Aim: Write a C program to declare a structure to store the information of 10 cricketers having
the following field
a. Cricketer name
b. Match played
c. Runs scored
d. Strike rate
Use a function to display the cricketer information having the maximum strike rate

Objective of the experiments:


To understand structure definition/declaration and union
Theory:
1. Explain structure with declaration and definition
2. Explain Union

Procedure: 1. Write the algorithm/Flow chart for a given program.


2. Write program based on algorithm
Software simulation
3. Start Compiler from C:\TC\BIN directory
4. Select NEW from File menu
5. Type program
6. Save the program
7. Compile and execute the program
Code: (Rule Side)
#include<stdio.h>
struct cricketer
{
int runs,wickets;
char name[25];
}player[100],t;

void main()
{
int i,j,n;
printf("Enter the no of cricket players\n");
scanf("%d",&n);
printf("Enter player info as name , wickets taken , runs scored\n");
for(i=0;i<n;i++)
{
scanf("%s %d %d",player[i].name,&player[i].wickets,&player[i].runs);
}

for(i=0;i<n;i++)
{
for(j=0;j<n-1;j++)
{
if(player[j].runs>player[j+1].runs)
{
t=player[j];
player[j]=player[j+1];
player[j+1]=t;
}
}
}

printf("\nCricketer info in terms of runs scored from lowest to highest\n");


printf("\nNAME\t\tWICKETS\t\t\tRUNS_SCORED\n");
printf("-------------------------------------------------------------------------------\n");

for(i=0;i<n;i++)
{
printf("%s\t\t\t%d\t\t\t%d\n",player[i].name,player[i].wickets,player[i].runs);
}
}

Algorithm/Flow chart : (Blank side)


Draw flow chart by considering structure and union

Output: (Blank side)

Conclusion : After successful execution of this experiment structure is studied well also
understood how to list structure members, by this experiment po 1,3,5,8,9,12 are achieved.

You might also like