You are given a C++ program that implements a simple sorting algorithm, such as bubble sort or insertion sort. The program sorts an array of integers in ascending order. However, the requirement now is to modify the code to sort the array in descending order instead. Formulate a question that prompts the candidate to identify the specific code segments that need to be modified and explain how they would make the necessary changes to achieve the desired sorting behavior
Sample Code:
“`cpp
#include
void bubbleSort(int arr[], int n) {
for (int i = 0; i < n – 1; i++) {
for (int j = 0; j < n – i – 1; j++) {
if (arr[j] > arr[j + 1]) {
// Swap arr[j] and arr[j+1]
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}
void printArray(int arr[], int size) {
for (int i = 0; i < size; i++) {
std::cout << arr[i] << " ";
}
std::cout << std::endl;
}
int main() {