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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started