go to previous page   go to home page   go to next page hear noise

Answer:

count = count + 1;

It increases count by one.

If this is not clear, remember the two steps of an assignment statement: first evaluate the expression on the right of the equal sign, second put the value in whatever variable is on the left. Say that count is 2. When the above statement executes, first the expression is evaluated, resulting in 3. Second the 3 is put in count.


Live Loop

while loop

Here is a simulation (using JavaScript) of the loop. Click on the "run program" button to see the output of the loop. Examine the flowchart to see how the looping is done.




 

If you look at the source for this page using your browser's "View Source" menu item, you will see the JavaScript that is responsible for the above. JavaScript is similar to Java, but has some big differences, so be careful not to get confused.

(If you want another example, click forward to page 11.)



QUESTION 3:

If the "3" where changed to a "10" how many times would the loop execute?