Question: Enter a string through the keyboard (For end use Ctrl+Z). The string should be copied into an output file text.txt. Then open an input file

Enter a string through the keyboard (For end use Ctrl+Z). The string should be copied into an output file text.txt. Then open an input file stream to read from the file text.txt. Each character that is an uppercase should be stored into an array text2[]. For checking use the function (isupper(char)). Print the array. Sum the ASCII codes of each element in the array and calculate the total ASCII code. Find the average ASCII code of the array. Create two sub-arrays:

The first one should contain all the uppercase letters whose ASCII code is less than the average ASCII code of the array,

The second one should contain all the uppercase letters whose ASCII code is greater than the average ASCII code of the array.

Put the last character of each array to be '\0'. Print the two arrays. If the number of elements in the first array is divisible by 2, sort the array with Buuble sort, else sort it with Quicksort. Similar, if the number of elements in the second array is divisible by 2, sort the array with Insertion sort, else sort it with Selection sort. Print the sorted arrays.

In C++

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 Accounting Questions!