Question: Please help me with the following C++ program. Solve the program using Visual Studio and make sure it runs well. Lab Assignment 21 - Sorting

Please help me with the following C++ program. Solve the program using Visual Studio and make sure it runs well.

Lab Assignment 21 - Sorting Arrays

  1. Program a program called Lab21 A. add a void function that receives an int array and its length as parameters. It should read 20 integers from text file (Lab21A.txt) and place them in the array. B. Write a void function that receives an int array and its length as parameters and prints the array elements on one line separated by spaces. C. Write a void function that receives an int array and its length as parameters. It uses the logic in the pseudocode below to sort the array. You will be printing the array several times (after each sorting pass) through the array, so each time you print it, you'll see one more element moving into the correct place. D. In the main function, declare an array of 20 integers; then call the function from step #a to populate it and the function to print it. After that call the function to sort it.

Pseudocode for sorting the array:

declare 3 variables: smallest, index & temp

for loop with i starting at 0 and ending at len-1

smallest = arr[i]

index = i

for loop with j starting at i+1 and ending at len

if arr[j]

smallest = arr[j]

index = j

end if

end for loop

swap arr[i] and arr[index] values (using temp as temporary holder)

call the function to print the array

end for loop

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