Question: Write a C program named lab4.c that sorts the following array of strings based on alphabetical order: char names[][16] = { Mike, Timothy, Katie, Anna,

 Write a C program named lab4.c" that sorts the following array

Write a C program named lab4.c" that sorts the following array of strings based on alphabetical order: char names[][16] = { "Mike", "Timothy", "Katie", "Anna", "Jennifer", "Barbara" }; Your program must implement the sort algorithm within a custom-defined function named sort_string() with the following signature and return type: void sort_string(char names[][16], int rows); This function must call functions strcmp() and strcpy() from the library inside a two-level nested for-loop to sort the sting array names based on alphabetical order. Your main() function must use a for loop to first display the individual strings stored in the names array. It must then call sort_string() to sort names, and finally use another for loop to display the sorted array names onto the console screen. Your program for this lab exercise must not use pointers and addresses. All array element access operations must use the offset operator [ ] that we have discussed in class

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!