Question 3

The following is a method/function of some class. Give the output of the function display() Show the dry run/working		public void display()
    	 {
      	    int arr[] = {10, 8, 14, 23, 15, 0, 9};
      	    int size = arr.length;
           for (int i = 0; i < size; i++) 
            {
                int j;
                for (j = i + 1; j < size; j++)  {
                     if (arr[i] <= arr[j])
                        break;
                  }
                  if (j == size) 
                  System.out.print(arr[i] + “ “);
             }	
         }
OUTPUT
23 15 9
This entry was posted in Term 2. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *