Answer to Question #203903 in C for Ankit

Question #203903

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.


1
Expert's answer
2021-06-06T08:56:37-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS