What is the value of z when the following code finishes executing?
int x;
int y;
int z;
x = 1;
z = 1;
while (x <= 5)
{
z = z + x;
x = x + 1;
}
I know the answer is 16 but I keep running into errors when trying to compute it. I feel like I'm messing up a step in the loop in the beginning. I know I can just plug this into a java client and get the answer but I'm really trying to understand the loop sequence so as to be able to do it by hand.
whileloops.