Answer:

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

Complete Program

Here is a complete program that lets the user pick the initial value and the limit value:

import java.util.Scanner;
// User picks starting and ending value
class loopExample
{
  public static void main (String[] args )  
  {
    Scanner scan = new Scanner( System.in );
    int count, limit;

    System.out.print( "Enter initial value: " );
    count = scan.nextInt();

    System.out.print( "Enter limit   value: " );
    limit = scan.nextInt();

    while ( count <= limit )   // less-than-or-equal operator
    {
      System.out.println( "count is: " + count );
      count = count + 1;
    }
    System.out.println( "Done with the loop" );
  }
}

Of course, you will want to copy this to a file and run this in the usual way.

QUESTION 10:

If the user sets the initial value to -2 and the limit value to 1 what values will be printed out?