// AP Computer Science, A Exam, 1996, Question 3, part B in C++ int DaysApart(Date d1, Date d2) // postcondition: returns 0 if d1 and d2 represent the same date; // otherwise, returns the number of days separating // the dates represented by d1 and d2 { int count = 0; Date temp; // swap if d1 > d2 if (d1 > d2) { temp = d1; d1 = d2; d2 = temp; } // assert: d1 <= d2 while (! (d1 == d2)) // only == defined, use !(...==...) { d1++; count++; } return count; }