Question: Write a C program to sort 40 randomly generated lowercase characters in ascending order (a to z) by using the insertion sort algorithm. The program

Write a C program to sort 40 randomly generated lowercase characters in ascending order (a to z) by using the insertion sort algorithm. The program should: a) Generate a random array of 40 lowercase characters [2 marks] b) Print the random array [1 mark] c) Sort the random array using insertion sort [6 marks] d) Print the sorted array [1 mark] In order to achieve the above objectives, your program should consist the following functions: a) A function called generateRandomChar to generate one random lowercase character. b) A function called printArray to print out the contents of an array. c) A function called insertionsort that carries out the insertion sort algorithm in ascending order. An example of the output is shown in Figure 3. Before: dayflxpicoyhtksvuguvpknmwmorskgxmgczdrhh After: accddfggghhhikkkimmmnoopprrsstuuvvwxxyyz Figure 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
