?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

For Loop

APCSA-ILGHL8

Consider the following code.

 int sum = 0;
 for (int counter = 2; counter <= 5; counter++)
  sum = sum + 2 * counter;

What is the value of sum after execution of the following code?

A

4

B

10

C

18

D

28

E

40