C Programming Code Examples C > Beginners Lab Assignments Code Examples Program to Sort Structures on the basis of Structure Element Program to Sort Structures on the basis of Structure Element Sorting Two Structures on the basis of any structure element and Display Information Program Statement - Define a structure called cricket that will describe the following information Player name Team name Batting average Using cricket, declare an array player with 10 elements and write a program to read the information about all the 10 players and print a team wise list containing names of players with their batting average. #include<stdio.h> struct cricket { char pname[20]; char tname[20]; int avg; } player[10], temp; void main() { int x, j, n; clrscr(); for (x = 0; x < 10; x++) { printf("\nEnter Player Name : "); scanf("%s", player[x].pname); printf("\nEnter Team Name : "); scanf("%s", player[x].tname); printf("\nEnter Average : "); scanf("%d", &player[x].avg); printf("\n"); } n = 10; for (x = 1; x < n; x++) for (j = 0; j < n - x; j++) { if (strcmp(player[j].tname, player[j + 1].tname) > 0) { temp = player[j]; player[j] = player[j + 1]; player[j + 1] = temp; } } for (x = 0; x < n; x++) { printf("\n%s\t%s\t%d",player[x].pname,player[x].tname,player[x].avg); } getch(); }