reset password
Author Message
myoung12
Posts: 1
Posted 14:30 Nov 25, 2013 |

R 7.9

Rewrite the following loops, using the enhanced for loop construct. Here, value is an array of floating-point numbers.

  1. for ( int i = 0; i < values.length; i ++ ) { total = total + values[i]; }
  2. for ( int i = 0; i < values.length; i ++ ) { total = total + values[i]; }
  3. for ( int i = 0; i < values.length; i ++)
    {
        if ( values[i] == target ) { return i; }
    }

Is loop 2 supposed to be different from loop 1?

Eric Liao
Posts: 158
Posted 14:48 Nov 25, 2013 |

Fixed.