Answer:
for (i = 0; datasamples[i] < NUM_POINTS ; ++i) {
if(datasamples[i] < minVal) {
datasamples[i] = datasamples[i] * 2;
}
}
Explanation:
In this particular problem, we are trying to look at each value in the datasamples array, and double it. This calls for the use of an index variable.
The index variable will keep track of the position within the array as we move from left to right. Starting on the left, at index 0, we will move right until we are at the end of the array.
++i takes care of incrementing the index variable each time the loop runs. This is what moves through the array.
The termination condition checks whether if we have iterates all values in the array. Once you've gone past all the values in the array the index variable is pointing all the way at the end.
As soon as the termination condition is false the loop will stop executing. So we will want to run your code while i (the index variable) is less than the size of the array (datasamples.length).
Once you've figured out the for loop bounds, simply check your conditional with an if-then statement before updating the values: