While Loop, Increment a value

How do I increment a particular value to an int? Using the while loop command.

Consider this pseudo-code:

int a = 1
while (a < 10) {
  a = a + 1
}

Oh! So it’s just the a = a +1 part, right?

Essentially, yes. We replace the old value with the new one computed from the expression, a + 1.

1 Like