< previous page page_a56 next page >

Page A56
   // Postcondition:
   //     firstNumber == firstNumber@entry / 2
   // && secondNumber == secondNumber@entry / 2

   {
       .
       .
       .
   }
7. a. Function definition:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
void ScanHeart( /* out */ Boolean& normal )

// Postcondition:
//     normal == TRUE, if a normal heart rate (6080) was input
//                     before EOF occurred
//            == FALSE, otherwise

{
    int heartRate;

    cin >> heartRate;
    while ((heartRate << 60 | heartRate > 80) && cin)
        cin >> heartRate;

    // At loop exit, either (heartRate >= 60 && heartRate <= 80)
    // or EOF occurred

    normal = (heartRate >= 60 && heartRate <= 80);
}
b. Function invocation:
ScanHeart(normal);
8. a. Function definition:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
void Rotate( /* inout */ int& firstValue,
             /* inout */ int& secondValue,
             /* inout */ int& thirdValue )
// This function takes three parameters and returns their values
// in a shifted order

// Precondition:
//     firstValue, secondValue, and thirdValue are assigned
// Postcondition:
//     firstValue == secondValue@entry
//  && secondValue == thirdValue@entry
//  && thirdValue == firstValue@entry

 
< previous page page_a56 next page >