What will the program print if the initialization is changed to:

    int count = 0;

A good answer might be:

count is 0
count is 1
count is 2
count is 3
Done with the loop

Boundary Conditions

What a loop does is affected by three activities. To decide what a loop will do, look carefully at the "boundaries" that these three activities establish:

  • Look at the first value.
  • Figure out the ending value by looking at the while loop condition.
  • Look at what change is made each time.
Look at the following program fragment:
    int count = 1;  
    while ( count <  4 )           // this is different 
    {
      System.out.println( "count is:" + count );
      count = count + 1;   
    }
    System.out.println( "Done with the loop" );      
Notice the changes from the previous program in the loop condition.

QUESTION 7:

What does the program print out?

Click Here after you have answered the question