Question: Exercise Objectives Sorting arrays ( bubble sort only ) Defining 2 D arrays Initialize 2 D arrays ( initializer list and using loops ) and

Exercise Objectives
Sorting arrays (bubble sort only)
Defining 2D arrays
Initialize 2D arrays (initializer list and using loops) and printing arrays
Problem Description
Write a C program that allows the user to enter weights for players in different teams, store their weights in a 2D array, and then sort the weights using the bubble sort algorithm.
Define a function called ReadWeights() that prompts the user to enter the weights for the players and stores them in a 2D array called weights[][] with a size of nm, where n is the number of teams and m is the number of players in each team.
2. Define a function called printWeights() that prints the weights stored in the weights[][] array
3. Define a function called Sort() that sorts the weights stored in the weights[][] array in ascending order using the bubble sort algorithm.
4. In the main:
Call ReadWeights() to prompt the user to enter the weights of players and store them in the weights[][] array.
Call printWeights() to print the weights before sorting
Call Sort() to sort the weights in descending order.
Call printWeights () to print the weights after sorting.
Sample Output:
Enter the number of teams: 3
Enter the number of players in each team: 4
Enter weights for players in team 1: 80.496.476.878.2
Enter weights for players in team 2: 76.987.581.279.9
Enter weights for players in team 3: 69.892.784.775.3
The weights of players:
In team 1: 80.4096.4076.8078.20
In team 2: 76.9087.5081.2079.90
In team 3: 69.8092.7084.7075.30
The weights of players in ascending order:
In team 1: 76.8078.2080.4096.40
In team 2: 76.9079.9081.2087.50
In team 3: 69.8075.3084.7092.70
Hint: you can use the bubble sort code:
Exercise Objectives Sorting arrays ( bubble sort

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!