Online Courses
Free Tutorials  Go to Your University  Placement Preparation 
Goeduhub's Online Courses @ Udemy in Just INR 570/-
Online Training - Youtube Live Class Link
0 like 0 dislike
1.3k 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.

Goeduhub's Top Online Courses @Udemy

For Indian Students- INR 570/- || For International Students- $12.99/-

S.No.

Course Name

 Coupon

1.

Tensorflow 2 & Keras:Deep Learning & Artificial Intelligence

Apply Coupon

2.

Natural Language Processing-NLP with Deep Learning in Python Apply Coupon

3.

Computer Vision OpenCV Python | YOLO| Deep Learning in Colab Apply Coupon
    More Courses

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

3.3k questions

7.1k answers

393 comments

4.5k users

Related questions

 Goeduhub:

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