1.)
Consider the following array definition:
int values[ 5] = { 4, 7, 6, 8, 2 };
What does the following statement display?
cout << values[ 4] << endl;
2 (on its own line)
The following statement, `cout << values[4] << endl;`, displays the element at index 4 of the `values` array.
To understand what this statement displays, we need to understand how arrays and indexing work.
In this array definition, `int values[5] = {4, 7, 6, 8, 2};`, we have an array named `values` of size 5, which means it can store 5 elements. The elements in this array are initialized with the values 4, 7, 6, 8, and 2.
In C++, arrays are zero-based, which means the first element in the array has an index of 0, the second element has an index of 1, and so on.
So, when we write `values[4]`, it refers to the element at index 4 in the `values` array. In this case, the fifth element of the array is 2.
Therefore, the statement `cout << values[4] << endl;` will display the value 2.