Question: This is a C++ programming problem. // Fig. 8.13: fig08_13.cpp // Selection sort with pass-by-reference. This program puts values into an // array, sorts them

This is a C++ programming problem.

This is a C++ programming problem. // Fig. 8.13: fig08_13.cpp // Selection

// Fig. 8.13: fig08_13.cpp // Selection sort with pass-by-reference. This program puts values into an // array, sorts them into ascending order and prints the resulting array. #include #include using namespace std;

void selectionSort( int * const, const int ); // prototype void swap( int * const, int * const ); // prototype

int main() { const int arraySize = 10; int a[ arraySize ] = { 2, 6, 4, 8, 10, 12, 89, 68, 45, 37 };

cout

for ( int i = 0; i

selectionSort( a, arraySize ); // sort the array

cout

for ( int j = 0; j

cout

// function to sort an array void selectionSort( int * const array, const int size ) { int smallest; // index of smallest element

// loop over size - 1 elements for ( int i = 0; i

// loop to find index of smallest element for ( int index = i + 1; index

if ( array[ index ]

swap( &array[ i ], &array[ smallest ] ); } // end if } // end function selectionSort

// swap values at memory locations to which // element1Ptr and element2Ptr point void swap( int * const element1Ptr, int * const element2Ptr ) { int hold = *element1Ptr; *element1Ptr = *element2Ptr; *element2Ptr = hold; } // end function swap

The objective of this homework is to give you experience usingfunction templates with C You will use the provided code in file: fig08 13.cpp as a starting point. The file is located in the Source Code folder on Learn For this assignment, you will write a function template selectionsort based on the code in figure 8.13 Write a driver program that inputs, sorts, and outputs an int array and a float array. Execute your test program and copy the outputs to a text file to demonstrate proper execution. What to submit Please submit a copy of your source code file and a text file(s) that includes execution output that demonstrates proper operation

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!