SUMMER TRAINING Free Tutorials  Go To Your University  Placement Preparation 
Project Based Best Summer Training Courses in Jaipur
Join our Telegram Channel To take free Online Courses
0 like 0 dislike
807 views
in GTU B.E. (CSE-I-Sem) Programming For Problem Solving Lab by Goeduhub's Expert (7.1k points)

Define a structure called cricket that will describe the following information:

Player name

Team name

Batting average

Using cricket, declare an array player with 50 elements and write a C program to read the information about all the 50 players and print team wise list containing names of players with their batting average.

1 Answer

0 like 0 dislike
by Goeduhub's Expert (7.1k points)
edited by
 
Best answer

In this program we are going to implement a structure called cricket which will hold three members as player name, team name, batting average. We will take input of these information from user and then print it to output window.

To learn about structure and union from beginning Click Here.

Example :

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

//Declaration of structure name cricket
struct cricket{

//Declaration of structure member variables
char player_name[30],team_name[30];
int bat_avg;
}player[50];

void main()
{
int i,n;
clrscr();

//To store information of as much players as much required
printf("\nEnter the number of players you want to include:");
scanf("%d",&n);

//To store information of players
printf("\nEnter the following information related to players");
for(i=0;i<n;i++)
{
printf("\nPlayer %d Name:",i+1);
scanf("%s",&player[i].player_name);
printf("\nTeam Name:");
scanf("%s",&player[i].team_name);
printf("\nBatting average:");
scanf("%d",&player[i].bat_avg);
}

//To print information of players
printf("\nEntered Information:");
printf("\n|| S.No. ||  Player Name      ||    Team Name    ||   Batting Average  ||");
for(i=0;i<n;i++)
printf("\n||  %d    ||   %s             ||       %s        ||          %d     ||",i+1,player[i].player_name,player[i].team_name,player[i].bat_avg);
getch();
}

Output :

Output of above program showing structure operation


For More GTU C Programming Lab Experiments Click Here

Our Mentors(For AI-ML)


Sharda Godara Chaudhary

Mrs. Sharda Godara Chaudhary

An alumna of MNIT-Jaipur and ACCENTURE, Pune

NISHA (IIT BHU)

Ms. Nisha

An alumna of IIT-BHU

Related questions

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy || Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 
...