Limited access

Upgrade to access all content for this subject

Consider the following code segment.

int x = 8;
int y = 0;
int z = 0;
while (y <=x)
{  
    z+=y;
    y++;
}

What will be the new value of z after the while loop finishes?

A

0

B

18

C

36

D

45

E

72

Select an assignment template