For Loop Array Iteration
What is the output when the following code segment is executed?
int[] arr = {7, 2, 5, 3, 0, 10};
for (int k = 0; k < arr.length - 1; k++)
{
if (arr[k] > arr[k + 1])
System.out.print(k + " " + arr[k] + " ");
}
A
0 2 2 3 3 0
B
7 2 5 3 3 0
C
0 7 2 5 3 3
D
0 7 2 5 5 10
Question Leaderboard
Not enough data yet to show leaderboard.
