Loop+Practice


 * Loop Practice**

Determine what is returned by each of theses methods when largest = 10. There is just a subtle difference in each

1) public int SumNumber { int count = 1; int sum = 0; while(largest > count) { count ++; sum += count; } return sum; }

2) public int SumNumber { int count = 0; int sum = 0; while (largest > count) { count ++; sum += count; } return sum; }

3) public int SumNumber { int count = 1; int sum = 0; while (largest > count) { sum += count; count ++; } return sum; }

4) public int SumNumber { int count = 0; int sum = 0; while (largest > count) { sum += count; count ++; } return sum; }

5) public int SumNumber { int count = 0; while (largest >= count) { sount += count; } return sum; }

6) public int SumNumber { int count = 1; int sum = 0; while( largest >= count) { count ++; sum += count; } return sum; }

7) public int SumNumber { int count = 0; int sum - 0; whiile (largest >= count) { count ++; cum += count; } return sum; }

8) public int SumNumber { int sount = 1; int sum = 0; while (largest >= count) { sum += count; count ++; } return sum; }

9) public intSumNumer { int count = 0; int sum = 0; while(largest >= count) { sum += count; count ++; } return sum; }

ANSWERS