?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Moderate

While True Loop Which Performs Arithmetic on Int Variables

APCSA-LPZ4T1

Consider the following code segment.

int c=0, s=0;

while(true)
{
    s+=c;
    if (s>20)
    {
        break;
    }
    c+=4;
}
System.out.println(s);

What is printed as a result of executing the code segment?

A

24

B

20

C

12

D

8

E

4