Write a „C‟ program to define a structure „cricket‟ having structure members as playername and battingaverage. Accept and display data for three players.
(Note: Any other correct logic shall be considered).
#include<stdio.h>
#include<conio.h>
struct cricket
{
char playername[10];
int battingaverage;
}c[3];
void main()
{
int i;
clrscr();
for(i=0;i<3;i++)
{
printf("\n Enter playername:");
scanf("%s",c[i].playername);
printf("\n Enter batting average:");
scanf("%d",&c[i].battingaverage);
}
for(i=0;i<3;i++)
{
printf("\n Player Name=%s",c[i].playername);
printf("\n Batting Average=%d",c[i].battingaverage);
}
getch();
}
0 Comments