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

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

Getting ready

If C:\files\lab14 exists, delete it.

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

Use PowerZip to extract the files to the C:\Files directory. This should create a C:\Files\lab14 directory with two subdirectories, Operate and Modify

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 functions:
Function  Operation 
Funky0 Adds all elements of the array and returns the total 
Funky1 Returns the largest element of the array 
Funky2 Returns the smallest element of the array 
Funky3 Adds all the even elements of the array and returns the total 
Funky4 Adds 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 functions:
Function  Operation 
Funky0 Adds one to each element of the array 
Funky1 Multiplies each element by three 
Funky2 Sets all array elements to zero 
Funky3 Sets the i'th array element to i
Funky4 Reverses 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