Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ #include <iostream> using namespace std; //template definition template<type

ID: 3668340 • Letter: C

Question

C++

#include <iostream>

using namespace std;

//template definition

template<typename T>

void BubbleSort(T* array, size_t count);

void showArray(int [], int);

int main()

{

     const int SIZE = 10;

     //numbers out of order

     int values[SIZE] = {};

    

     //display

     cout << "Vales: ";

     showArray(values, SIZE);

     return 0;

}

//void BubbleSort(T* array, size_t count)

void BubbleSort(T* [], int);

{

     int temp;

     bool swap;

     //keeps on looping to get it in order

     do

     {

           swap = false;

                for (int count = 0; count < (size - 1); count++)

                {

                     if (array[count] > array[count - 1])

                     {

                           temp = array[count];

                           array[count] = array[count + 1];

                           array[count + 1] = temp;

                           swap = true;

                     }

                }

     }while (swap);

    

}

//display content

void showArray(T* array, size_t count)

{

     for (int count = 0; count size; count++)

           cout << array[count] << " ";

           cout << endl;

}

Problem 2: Your manager wants a printed table as above, but sorted by audience popularity e as above, but sorted by audience pop Write the function: void SortMoviesByAudienceRating(Movies movies, int nuMovies); int numMovies); Modify the BubbleSort you wrote in Home Work 2 to sort your movies based on Modify the Bubble Sort you wrote in Home Work 2 to sort your movies based orn the audienceRating member variable. Test it by using the print function from Problem 1.

Explanation / Answer

there is no error in code just see the template usage and the code is working and ofcourse sorting too