1. Write a program in C that reads a list of student names and sorts the list. Y
ID: 3686049 • Letter: 1
Question
1. Write a program in C that reads a list of student names and sorts the list. Your program should have a function called “readNames” that has two arguments: 1) a 2-D character array, 2) an integer indicating the number of student names to be read from the keyboard. Another function called “sortNames” should have the same arguments and will reorder the list using a sorting algorithm (similar to the one we implemented for integer arrays) and puts names in ascending order. Assume that names are not longer than 10 characters including the nul character (‘’). Also, maximum number of names that will be entered by the user is 10.
Note 1: The 2-D character array serves as a way to store names. Each row of this array will save a single name (assuming we are only reading first names and they don’t include any spaces). For example if the user enters 3 names: Alex, Jack, and Rebekah, the 2D array would look like this:
Note 2: You can define the character array as: char names[10][10]; At the end, write a main function that utilizes these two functions to read N names (main function should read N from the keyboard) and print them in ascending order.
Explanation / Answer
#include #include void main() { char name[10][8], tname[10][8], temp[8]; int i, j, n; printf("Enter the value of n "); scanf("%d", &n); printf("Enter %d names n", ); for (i = 0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.