Question: We are currently working on Arrays and Algorithms and I would appreciate some help with the function and below the picture is the support file.

We are currently working on Arrays and Algorithms and I would appreciate some help with the function and below the picture is the support file.

We are currently working on Arrays and Algorithms and I would appreciate

/**

CS 150 PARTIALLY FILLED ARRAYS

Follow the instructions on your handout to complete the

requested function. You may not use any library functions

or include any headers, except for for size_t.

*/

#include // size_t for sizes and indexes

///////////////// WRITE YOUR FUNCTION BELOW THIS LINE ///////////////////////

// function here

///////////////// WRITE YOUR FUNCTION ABOVE THIS LINE ///////////////////////

// These are OK after the function

#include

#include

#include

using namespace std;

string toString(const int a[], size_t size);

void studentTests()

{

cout

cout

int a[100] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};

size_t size = 12;

cout

cout

int numRemoved = removeEnds(a, size);

cout "

cout 2"

size--;

cout

cout

numRemoved = removeEnds(a, size);

cout "

cout 3"

cout

size = 1;

cout

numRemoved = removeEnds(a, size);

cout "

cout -1"

cout

cout

}

string toString(const int a[], size_t size)

{

ostringstream out;

out

if (size > 0)

{

out

for (size_t i = 1; i

out

}

out

return out.str();

}

int main()

{

studentTests();

}

3 THE removeEnds PROBLEM Write the function removeEnds () that removes the first and last element in the array, except that, if the array size is odd, it removes the first two elements along with the last element. The function takes 2 arguments: the array of int that will be modified the size of the array (use size t as the type) Both of these may be changed by the function. The function returns the number of items removed or -1 if the array has too few elements int numRemoved removeEnds (a, size); Input-output parameters

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!