Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 12 pages
Exam (elaborations)

EECS 280 Midterm || Detailed Solutions Offered.

Document preview thumbnail
Preview 2 out of 12 pages

EECS 280 Midterm || Detailed Solutions Offered.

Content preview

EECS 280 Midterm || Detailed Solutions Offered.
Types of testing correct answers Unit testing, system testing, Regression testing

Unit Testing correct answers - Test smaller, less complex, easier to understand units

- One piece at a time (e.g., a function)

System testing correct answers - Test entire project (code base)

- Do this after unit testing

- Regression testing correct answers - Automatically run all unit and system tests after a code
change

Steps to test: correct answers 1. Understand the specification

2. Write tests

3. Check the results

Arrays correct answers An array is a fixed-sized, indexed, homogeneous aggregate type (a
collection of items, all of the same type.)

declare arrat correct answers int bar[4]; // Array, int bar[4] = {1, 2, 3, 4}; // Static Initializer

accessing array elements correct answers - You can access the contents of an array using an
"index". The index of the first array element is zero, the

next is one, and so on.

- Each individual element is used just like a regular int, so all of the following are legal:

1 // array = {1, 2, 3, 4}

2 array[1] = 6;

3 // array = {1, 6, 3, 4}

4 ++array[1];

5 // array = {1, 7, 3, 4}

6 array[0] = array[1];

7 // array = {7, 7, 3, 4}

Passing arrays to functions correct answers C++ arrays can be passed as arguments to a
function.

, - Suppose we wanted to write a function to add up the contents of an array and we want it to
work with any

size array.

- Here's what the declaration of such a function might look like:

5

Programming and Introductory Data Structures 3.4 Thinking about memory

1 int sum(inta[], unsigned int size);

2 // REQUIRES: there are at least size elements in a[]

3 // EFFECTS: returns the sum of the first size elements of a[]

- Important things to notice:

1. The declaration of the array argument does not specify the length of the array. That allows
the function

to work for any length.

2. sum() needs to know how long the array actually is (or at least, how many elements to
"sum up"), so

the second argument does this.

3. An unsigned intis used for size since it cant be negative. A regular intcould be used, but
then the

REQUIRES clause would need to catch cases of negative sizes. Its better to write a complete
function.

- Unlike most types we've seen so far, C++ arrays are notpassed by value. They are passed by
reference.

declare a pointer to int correct answers int *foo

bar is a pointer to int correct answers 1 int foo;

2 int *bar;

3 bar = &foo;

4 foo= 1;

- The symbol "&" means "address-of". So, this statement says that "bar is a pointer to an
integer, initialized

Document information

Uploaded on
November 19, 2025
Number of pages
12
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$12.39

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
SirAnton
3.7
(118)
Sold
791
Followers
438
Items
39797
Last sold
6 days ago


Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions