Please send questions to st10@humboldt.edu .

// Contract: swap : int& int& -> void
// Purpose: simple example swapping the values of 
//          two variables --- this function will
//          cause the argument corresponding to
//          val1 to contain the argument corresponding
//          to val2's original value, and the argument 
//          corresponding to val2 to contain the argument
//          corresponding to val1's original value.
//
// Examples: if num1 == 3 and num2 == 5, then after:
//           swap(num1, num2);
//           ... num1 == 5 and num2 == 3.
//
// by: Sharon M. Tuttle
// last modified: 10-28-03

void swap(int& val1, int& val2)   
{
    // local variables
    int temp;

    // try to swap val1's and val2's values
    temp = val1;
    val1 = val2;
    val2 = temp;
}