Limited access

Upgrade to access all content for this subject

Consider the following code segment.

int[] nums = // array of integers
int i=0, h=nums.length-1;

while (i<nums.length/2 && h>=0)
{
    int r = nums[i];
    nums[i] = nums[h];
    nums[h] = r;
    i++;
    h--;
}

Which of the following BEST describes the function of the code segment?

A

It sorts nums in descending sequence.

B

It sorts nums in ascending sequence.

C

It reverses the elements in nums.

D

It shifts the elements in nums up one position.

E

The elements in nums remain in their original order.

Select an assignment template