Question: Add the following functions to the program BELOW and test by calling from main(): // Print out the contents of an array // Pre: Valid
Add the following functions to the program BELOW and test by calling from main():
// Print out the contents of an array
// Pre: Valid array and number of elements in the arry
// Post: Prints array contents void PrintArray(/* IN */ const int[], /* IN */ int);
// Compares if two arrays contain equivalent elements and
// returns true or false // Pre: Both arrays contain the same number of elements,
// that number is in the third parameter
// Post: Returns true if the arrays are equal, false otherwise bool CompareArrays(/* IN */ const int[], /* IN */ const int[], /* IN */ int);
THIS IS THE PROGRAM!!
#include
using namespace std;
void InitArray(float arr[], int n){
cout << "Enter " << n << " values: " << endl;
for(int i=0; i cin >> arr[i]; } } float SumArray(float arr[], int n){ float sum=0; for(int i=0; i sum += arr[i]; } return sum; } int main() { float arr[5]; InitArray(arr, 5); cout << "The sum is " << SumArray(arr, 5) << endl; return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
