Question: please use C Q2. Write a program that uses Selection Sort to sort a list of people. To do this, define a struct that holds

please use C Q2. Write a program that uses Selection Sort tosort a list of people. To do this, define a struct thatplease use C

Q2. Write a program that uses Selection Sort to sort a list of people. To do this, define a struct that holds information about a person: their age (as an int) and their first name (a string of no more than 25 characters). Have the user input how many people should be in the list, and then have the user input a first name and age for each person. (See the sample output below). The information should be stored in an array of structs. As before, you must use pointer notation when referring to this array. Then ask the user whether they would like to sort the list by age or into alphabetical order. Have the user enter 0 for age, and 1 for alphabetical order. No input validation is required for this assignment. Then you must modify the Selection Sort algorithm you came up with for question 1 to sort the array. Try to think about what must be changed: Your array holds a different data type now, so you must adjust the algorithm to match. What are you sorting by now? How does that change the comparisons you must make? Try to implement sorting by age first. Then think about how you can sort alphabetically. For simplicity, you only need to sort by the first letter of the person's name. You don't need to create two completely separate Selection Sort algorithms for this assignment. How can you use one loop and sort the way the user chose? Sample output: How many people would you like to enter? 5 Please enter person 1's first name and age: Timmothy 18 Please enter person 2's first name and age: Andrew 6 Please enter person 3's first name and age: Brewster 85 Please enter person 4's first name and age: Morgan 31 Please enter person 5's first name and age: Baby 5 Would you like to sort by age or alphabetical order? Enter O for age, 1 for alphabetical order (first letter only): 0 The sorted list: Baby, 5 Andrew, 6 Timmothy, 18 Morgan, 31 Brewster, 85

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 Databases Questions!