CIT020 Index > C++ Assignment: References

C++ Assignment: References

Read everything before doing anything.

Function main( )

You will write a program in a file whose name is in the form lastname_firstname_refs.cpp. Thus, if your name is Zoltan Karpathy, your file would be named karpathy_zoltan_refs.cpp.

The main() function of your program will:

  1. Define an integer constant named N_SCORES with a value 10.

  2. Create an int array of ten items. The name of this array must be data. Initialize the array to these values:

    30, 41, 56, 51, 145, 90, 22, 76, 92, 49
  3. Create int variables named highScore and lowScore, both set to zero.

  4. Call a function named boostLowScores( ), which will add twelve points to any score that is less than 50.

  5. Print the contents of the data array.

  6. Call a function named findMinMax( ), which will go through the array and return the lowest and highest scores in the array by reference.

  7. Print the contents of the highScore and lowScore variables, properly labelled.

Important: Only the main( ) function will do output; neither of the following functions will use cout.

The boostLowScores function

This function returns void and takes two parameters: an array of int and an int telling how many items are in the array. This function does not do any output to the screen (i.e., it does not use cout).

The findMinMax( ) function

This function takes four parameters: an array of int, an int telling how many items are in the array, a by-reference int to return the low score, and a by-reference int to return the high score. This program does not produce any output on the screen (i.e., it does not use cout). It also returns void.

When You Finish

When you finish,attach the .cpp file to an email; put "CIT020 References" in the subject line and send the email to the instructor.