need this done by tomorrow 6 pm eastern, i have no time and will not be checking jsp till around 5pm eastern so yea
assignment 1
1. Write a complete C++ program that will contain the given 3 functions and contain all test
statements to test out the functions.
a. Write a function called firstIndex that finds the smallest index of an entry in an array
of integers that matches a given target. If the target is not present the function should
return an answer of −1.
For example, a program that uses the function follows.
int main() {
int x[6] = {3, 1, 4, 1, 5, 9};
int capacity = 6;
int target = 5;
cout << firstIndex(x, capacity, target) << endl;
// prints 4 because the target 5 is found as element number 4
cout << firstIndex(x, capacity, 1) << endl;
// prints 1 because the target 1 is first found as element number 1
cout << firstIndex(x, capacity, 8) << endl;
// prints -1 because the target 8 is not found.
return 0;
}
b. Write a function called reduceFrac that will reduce the given fraction into the lowest
term.
For example, a program that calls the function will have the output
cout << reduceFrac(5, 100) // prints out 1/20
assignment 2
1. Write a complete C++ program that will contain the following :
a. 2D array of size 10 by 10 containing only integers.
b. 1D array of size 10 containing only doubles.
c. Write a function randFill that will fill the 2d array with random numbers that is
generated in between 50 – 100.
d. Write a function averageCol that will calculate the average of a column in the 2D
array. Store the respective average of each column in the 1D array.
e. The main program should write all the test statements that will print out all the
elements in the 2d array (10 numbers per line), and also print out the newly calculated
average in the 1d array.