Limited access

Upgrade to access all content for this subject

What will print to the console when the following code segment is executed?

int[] nums = {1, 2, 3};
int tot = 0;

for (int i=0; i<nums.length; i++)
{    
    for (int j=nums.length-1; j>0; j--)
    {
        tot += nums[i]*nums[j];
    }                
}
System.out.println(tot);
A

6

B

12

C

27

D

30

E

36

Select an assignment template