Question
----------C PROGRAMMING---------- 1. Sorting and Searching Write a menu driven program that can sort an array of student structures by several di erent criteria as
----------C PROGRAMMING----------
1. Sorting and Searching Write a menu driven program that can sort an array of student structures by several di erent criteria as well as search for students from the array. The student structure (name it as Student) should have the following components: rst name, last name, and student ID. The array of student structures should be dynamically allocated and grown on demand with the realloc function of the < stdlib.h > library header file.
The main function should declare a Student pointer and set it to NULL. The Student
array size variable should be 0 initially. Then the menu should be displayed. It is assumed that a first-time user will choose option 1 first and add students in the array. Student *array = NULL; int size = 0; ............................... 1: Add new student 2: Find student by first name, last name 3: Find student by ID number 4: Sort ascending by first name 5: Sort ascending by last name 6: Sort descending by first name 7: Sort descending by last name 8: Sort ascending by ID 9: Exit Option 1: Upon choosing this option, a user is prompted to enter a student first name, last name and ID. Then the Student array should be reallocated to increment its size by 1. In the last array block (newly created via reallocation), the Student struct would be stored. The choice of search and sort functions is left up to the programmer. Assumptions: (a) You may assume that student ID field will be unique to each student. (b) You may assume that a name will always be less than 100 characters in length for both parts individually. (c) You may assume that first and last names will not contain any white space characters. Data Type Requirement: First and last name are character strings of max size 100 each and ID is an integer. Input Validation: Any valid character string and integer is valid for input into a student structure, but you should perform input validation on the menu choices
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started