Question: Rewrite the following loops, using the enhanced for loop construct. Here, values is an array of floating-point numbers. a. for (int i = 0; i
Rewrite the following loops, using the enhanced for loop construct. Here, values is an array of floating-point numbers.
a. for (int i = 0; i < values.length; i++) { total = total + values[i]; }
b. for (int i = 1; i < values.length; i++) { total = total + values[i]; }
c. for (int i = 0; i < values.length; i++)
{
if (values[i] == target) { return i; }
}
Step by Step Solution
3.31 Rating (181 Votes )
There are 3 Steps involved in it
The following loops using the enhanced for loop co... View full answer
Get step-by-step solutions from verified subject matter experts
