Cricketer List Team-wise Structures coderinme

Cricketer List Team-wise Structures coderinme

Cricketer List Team-wise Structures coderinme
Define a structure called cricket that will describe the following information:
a. Player name
b. team name
c. batting average
Using cricket, declare an array player with 5 elements and write a program to read the information about all the 50 players and print a team-wise list containing names of players with their batting average.

#include<stdio.h>
#include<string.h>
#define total 5
struct cricket
{
char nm[20],team[20];
int avg;
};
int main()
{
struct cricket player[total],temp;
int i,j;
for(i=0;i<total;i++)
{
printf("For player %d\n",i+1);
printf("Enter the name of player : ");
fflush(stdin);
gets(player[i].nm);
printf("Enter the team : ");
fflush(stdin);
gets(player[i].team);
printf("Enter the batting average : ");
fflush(stdin);
scanf("%d",&player[i].avg);
}
printf("\nTeam Name Average\n");
printf(" \n");
for(i=0;i<total;i++)
{
printf("%-10s %-10s %7d\n",player[i].team,player[i].nm,player[i].avg);
}
getch();
return 0;
}

For more programs in C, visit our C Archives

Cricketer List Team-wise Structures coderinme

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme

Leave a reply:

Your email address will not be published.