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

The goal of the program is to have array1 have the smaller value for each index

ID: 3631235 • Letter: T

Question


The goal of the program is to have array1 have the smaller value for each index of the array. The goal is _not_ to have array1 have all of the smaller values, but to have at each index the smallest value. Hence, the two arrays may originally contain the values:

array1: 1 24 19 100 47
array2: 17 34 44 19 34

after the program runs the arrays will have the value:

array1: 1 24 19 19 34
array2: 17 34 44 100 47

Create two arrays of 10 items each, array1 and array2. A user will input values into the arrays. your program should output the arrays so that the user can verify the input. Your program will walk through each array, place by place. for each index of the array, the program will compare values. if the value in array2 is larger than the value of array1, the program will swap the two values between the two arrays. After the swaps are complete, the program should output the new arrays.

Note that the assignment calls for you to allow for partially filled arrays. You should have the user input the same number of values for both array1 and array2.


your program must use the following functions:

void swap(int& num1, int& num2);

void printArray(int arrayA[], int numberUsed);

You may include other functions you believe are logically justified.

Explanation / Answer

#include using namespace std; void swap(int& num1, int& num2) { int temp = num1; num1 = num2; num2 = temp; } void printArray(int arrayA[], int numberUsed) { for(int i=0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote