Create a structure IPL2022 with member’s team_name, matches_palyed,
won, lost, tied and total_points. There are 10 Teams participating in IPL.
Write a program to ask the user to enter the details team_name,
matches_palyed, won, lost, and tied; and calculate total_points for each
team. Display the final points table of IPL2022.
#include<stdio.h>
#include<stdlib.h>
struct IPL2022{
//team_name, matches_palyed, won, lost, tied and total_points.
char team_name[20];
int matches_played;
int won;
int lost;
int tied;
int total_points;
};
int main( void){
int i;
struct IPL2022 teams[10];
for(i=0;i<10;i++){
printf("Enter team name: ");
gets(teams[i].team_name);
printf("Enter team matches played: ");
scanf("%d",&teams[i].matches_played);
printf("Enter team matches won: ");
scanf("%d",&teams[i].won);
printf("Enter team matches lost: ");
scanf("%d",&teams[i].lost);
teams[i].tied=teams[i].matches_played-teams[i].won-teams[i].lost;
teams[i].total_points=3*teams[i].won+teams[i].tied;
fflush(stdin);
printf("\n");
}
printf("\n%-15s%-15s%-15s%-15s%-15s%-15s\n","Team name","Matches played","Won","Lost","Tied","Total points");
for(i=0;i<10;i++){
printf("%-15s%-15d%-15d%-15d%-15d%-15d\n",teams[i].team_name,teams[i].matches_played,teams[i].won,teams[i].lost,teams[i].tied,teams[i].total_points);
}
getchar();
getchar();
return 0;
}
Comments
Leave a comment