EECS 183 Labs

EECS 183 Lab 5: Arrays

Lab due on your scheduled lab day

Lab accepted for full credit until Monday, March 7, 2022, 11:59 pm Eastern

In this lab, you are writing code and solving practice exam questions to master the use of arrays.

After completing this lab, you will be able to:

You should complete this lab in small groups of about 4 students. For all labs in EECS 183, to receive a grade, every student must individually submit the Lab assignment.

Starter Files

You can download the starter files using this link.

The IDE setup tutorials for Visual Studio and XCode include a video about how to set up a project using the starter files. You can access the tutorials here:

After downloading and unzipping, you will find the following files in the starter-files folder:

IMPORTANT: For this lab, you must include all three files in a single project in Xcode or Visual Studio.

Lab Assignment Part 1 - arrays.cpp

Tasks to Complete

  1. Start a new project with your IDE using the starter files according.
  2. Stub all of the functions in arrays.cpp - see Function Stubs for details.
  3. Write your test cases in test.cpp to test the functions you will implement in arrays.cpp.
  4. Write the implementations for the functions in arrays.cpp:
    • negate_all()
    • is_sorted()
    • copy_positive_elements()
    • sort_array()
  5. Test your functions using the test cases you have written.
  6. Submit your arrays.cpp to the autograder.
    • For this lab, you will not submit test.cpp

Multiple Files

Function Stubs

A function stub is a temporary substitute for a to be implemented function. In all projects and labs so far in EECS 183, we have provided all of the function stubs for you. Like the previous lab, you will need to create function stubs for all of the functions you will implement.


int values[5] = {1, -2, 3, -4, 5};
negate_all(values, 5);
print_array(values, 5);
{-1, 2, -3, 4, -5}


int values1[5] = {1, -2, 3, -4, 5};
int values2[6] = {1, 2, 3, 3, 4, 5};
cout << is_sorted(values1, 5) << endl;
cout << is_sorted(values2, 6) << endl;


NOTE: Zero is not a positive number.

int values1[5] = {1, -2, 3, -4, 5};
int values2[5] = {2, 0, 8, 5, 1};
copy_positive_elements(values1, values2, 5);
print_array(values2, 5);
{1, 3, 5, 0, 0}


int values1[5] = {1, -2, 3, -4, 5};
sort_array(values1, 5);
print_array(values1, 5);
{-4, -2, 1, 3, 5}

How to Submit

IMPORTANT: For all labs in EECS 183, to receive a grade, every student must individually submit the Lab Submission. Late submission for Labs will not be accepted for credit. For this lab, you will receive ten submissions per day with feedback.

Lab Assignment Part 2 - RME Canvas Quiz


RMEs (Requires, Modifies, Effects) are the comments that appear above function declarations for labs and projects. They document what a programmer needs to know to be able to call a function. These comments also contain essential information needed to write the function definitions for labs and projects.

  1. Take a few minutest to review the slides on RME’s here.
  2. Complete the Canvas quiz Lab 5 - RME Quiz.. You have an unlimited number of attempts for the quiz, but must complete it by the date at the top of this document.