Question: //Write functions sum and printEvenIndex //Write function title of fun, change, swapIt. #include using namespace std; int fun(int a[][2], int b[], int c); void change(int
//Write functions sum and printEvenIndex //Write function title of fun, change, swapIt. #includeusing namespace std; int fun(int a[][2], int b[], int c); void change(int a[], int inc); void swapIt(int &a, int &b); int range(int a[][2], int row, int col){ int sm = a[0][0]; //assume the first element is the smallest and largest int lg = a[0][0]; for (int r = 0; r < row; r++){ for (int c = 0; c < col; c++){ if (a[r][c] < sm) sm = a[r][c]; else if (a[r][c] > lg) lg = a[r][c]; } } return lg - sm; } int main(){ double arr[6] = {2.3, 4.1, 5.3, 1.3, 6.5, 0.2}; cout << gapSum(arr, 6) << endl; //prints 18.5 cout << sum(arr[1], arr[4]) << endl; //prints 10.6 printEvenIndex(arr, 6); //prints out 2.3 5.3 6.5 int x[3][2] = {{1,2},{3,3},{4,5}}; int y[4] = {1,2,3,4}; cout << x[1][0]; // What is the output of this line? for (int i = 0; i < 2; i++) cout << x[i][i] << endl; // What's the output? cout << y[y[1]] << endl; // Output? y[3] = fun(x, x[0], x[0][0]); change(y, 2); //doubles all the values in y, y becomes 2 4 6 8 x[0][0] = 0; swapIt(x[x[0][1]][x[0][0]], y[0]); //exchange the values in y[0] with x[x[0][1]][x[0][0]] int num_range = range(x, 3, 2); cout << "The range is " << num_range << endl; return 0; }
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
