Limited access

Upgrade to access all content for this subject

Consider the following code segment which is coded incorrectly. The intention of the loop is to count the number of elements in the array greater than 20

int[] nums = /* nums points to a valid array of integers */
int count=0;

for (int e : nums)
{
    if (nums[e] > 20)
        count++;
}

Which of the following statements is TRUE after executing this code segment?

A

The variable count will contain the number of integers that are greater than 20 in the array .

B

The variable count will be greater than 0.

C

The code would throw an error if nums contains {29, 10, 52, 36, 4}.

D

The code would throw an error if nums contains {2, 0, 3, 1}.

E

The code will always throw an error.

Select an assignment template