Question: USING C++ Consider the following code: te mplate T F2(T* A, int n, int p) { for (int i = 0; i < p; i++)

USING C++ Consider the following code:

template  T F2(T* A, int n, int p) { for (int i = 0; i < p; i++) { int maxi = i; for (int k = i + 1; k < n; k++) if (A[k] > A[maxi]) maxi = k; swap(A[maxi], A[i]); } return A[p-1]; } int main() { int X[10] = { 13, 44, -2, -8, 19, 20, 21, 100 }; int M2 = F2(X, 8, 2); return 0; } 

What is the value of the variable M2?

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!