int sum = 0;
for (int index = 0; index < arr.length; index++)
{
sum += arr[index];
}
It can also be rewritten using a for-each loop in the following way:
.
int sum = 0;
for (int index : arr)
{
sum += index;
}
for (int index : arr)
{
sum += index;
}
Completely suitable, 100 XPs for this completion.
ReplyDelete