For this C++ called getArrayLength that counts up the number of elements in an array of integers that ends with the sentinel value, -999.
For this C++ called getArrayLength that counts up the number of elements in an array of integers that ends with the sentinel value, -999.
The only parameter needed is the array. Finish the function below. This function will be used in solution for the next question.
#include <iostream>
using namespace std;
/*
* int getArrayLength(int srcArray[])
* @param: an array of integers that ends in the sentinel value -999
* @returns: the length of the array not including the sentinel value.
*/
int getArrayLength(int srcArray[])
{
// ToDo: Fill-in the code to count the good values in the array.
}
int main()
{
int array[] = { 1, 3, 5, 7, 9, 11, -999 };
cout << "The array has " << /* ToDo: call your function */ << " elements in it.\n";
return 0;
}

Step by step
Solved in 2 steps with 2 images









