CS 1405 - Lab 12

Objective

  1. Program with arrays

Preparation

  1. Read sections 7.1 - 7.7 from Starting Out with C++ by Gattis.
  2. Print and complete Worksheet 12.

Programming

  1. Write a function, printArray, that receives a integer array and also an integer indicating how many numbers are in the array.  It prints all numbers in the array, one per line.
  2. Write a function called loadArray that accepts two parameters; an integer array and an integer specifiying the capacity of the array.  It assigns each element of the array a random integer in the range 0 to 100 inclusive.
  3. Write a function called findMax that accepts two parameters; an integer array and an integer specifying the capacity of the array. It determines and returns the maximum value in the array.
  4. Write prototypes for the functions printArray, loadArray and findMax.
  5. Write a driver program that demonstrates the three functions.  The driver program should create an integer array of capacity 20.  It should load the array by calling loadArray.  It should print the contents of the array by calling printArray.  Then it should output the maximum value in the array by calling findMax and displaying the value returned. Be sure to document the functions correctly by including complete specifications with the definitions.
  6. Verify the program works correctly.
  7. Print the Grade Sheet.  Show your program to the instructor.

150 East College Avenue * Ephraim, Utah 84627 * Email: ude.wons@nosneros.htrag
© 2014 Snow College * All Rights Reserved
©