CSCI 201 Lab 13 -- More Arrays in C++

I this lab you'll operate on all the elements of an array and you'll also modify an array.

Getting ready

If C:\FILES\Lab13 exists, delete it.

Download a ZIP'ed copy of the Lab 13 projects and store it in the C:\FILES directory.

Go into the MS-DOS prompt and execute the following commands:

Operating on Arrays

Open and build the project C:\FILES\Operate\Operate.dsw. Look at the C++ code in the file Operate.cpp. The five routines Funky0 to Funky4 are set up to receive an array of integers and return a single integer. The first routine is already done. It adds up the elements of the array and returns the total.

Lab checkoff I

Your job is to finish off the other four routines. When you are done, your program should have the following five five functions:
FunctionOperation
Funky0Adds all elements of the array and returns the total
Funky1Returns the largest element of the array
Funky2Returns the smallest element of the array
Funky3Adds all the even elements of the array and returns the total
Funky4Adds the smallest and largest elements of the array and returns their sum

Modifying Arrays

Open and build the project C:\FILES\Modify\Modify.dsw. Look at the C++ code in the file Modify.cpp. The five routines Funky0 to Funky4 are set up to receive an array of integers. They return no values. The first routine Funky0 adds one to each element of the array.

Lab checkoff II

Your job is to finish off the other four routines. When you are done, your program should have the following five five functions:
FunctionOperation
Funky0Adds one to each element of the array
Funky1Multiplies each element by three
Funky2Sets all array elements to zero
Funky3Sets the i'th array element to i
Funky4Reverses the array, that is, switches the first and last elements, etc.

Return to CSCI 201 page
CSCI logo Return to the UNCA Computer Science home page