Question: Write a C program to sort 30 randomly generated uppercase characters in descending order (Z to A). Use the selection sort algorithm . The program

Write a C program to sort 30 randomly generated uppercase characters in descending order

(Z to A). Use the selection sort algorithm.

The program should:

a) Generate a random array of 30 uppercase characters

b) Print the random array

c) Sort the random array using selection sort

d) Print the sorted array

--------------------------------------------------------------------------------------------

In order to achieve the above objectives, you may choose to follow the suggestions below:

a) Write a function called generateRandomChar to generate one random

character. This function has no input argument but returns a char (i.e. the random

character). Call this function 30 times in the main function to generate 30

uppercase characters and assign each of these characters as an element of an array.

Hint: Use the function rand() to generate random integers

b) Write function called printArray to print out the contents of an array. The

functions input argument is the char array that has to be printed. The function

does not return any value.

c) Write a function called selectionSort that carries out the selection sort

algorithm. The functions input argument is the char array containing unsorted

uppercase characters. The function does not return any value.

d) Call the printArray function accordingly in main function.

An example of the output is:

Before: NWLRBBMQBHCDARZOWKKYHIDDQSCDXR

After: ZYXWWSRRRQQONMLKKIHHDDDDCCBBBA

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!