1.
Q24: What does the following code accomplish? Assume that
alpha
is a correctly declared array with non-default values and that the variable target
contains a value.
int place = -1;
int index = 0;
for (int x : alpha) {
if (x == target)
place = index;
index += 1;
}
place
always contains -1- the code does not work because you can’t get the index with an enhanced for loop