Q:

Intro to C++: Sorting code

I am studying for a final exam that is scheduled today. My question is, what does the do-while(swap) statement do here? Is swap set to "true" by default? 
My understanding of this code is that it iterates at least once for each pass of the sort. The inner for loop carries the crucial code and does all the swaps in the pass. For example, array[count] is copied into temp, array[count+1] is copied into array[count] and array[count] is copied into array[count+1]. If the two elements are swapped, the bool swap is set to true. The outer loop keeps iterating until it finds the swap flag false. 
void sortArray(int array[], int size)
{
   int size;
   bool swap;

do
{
   swap = false;
   for(int count = 0; count < (size -1); count++)
   {
      if(array[count] > array[count+1])
      {
         temp = array[count];
         array[count] = array[count+1];
         array[count+1] = temp;
         swap = true;
       }
    }
  }while(swap);
 }

A:

Swap is used to check if algorithm is still sorting or not. If swap is false, it means that array is already sorted and algorithm can be finished.
By default (in the beginning of each iteration of do-while loop) swap is set to false and it's change to true only if swap was made (it means that array elements weren't in correct order).

