Question: Write the function removeN() which removes N elements from the array starting at a given position. We are currently working on Arrays and Algorithms and

Write the function removeN() which removes "N" elements from the array starting at a given position.

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.Write the function removeN() which removes "N" elements from the array starting

/**

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

cout

{

const int CAP = 30;

int a[CAP] = {10, 54, 81, 45, 95, 25, 10, 95};

size_t size = 8;

cout

cout "

bool ok = removeN(a, size, 3, 2);

cout " "

cout [10, 54, 25, 10, 95], return->true"

}

{

const int CAP = 30;

int a[CAP] = {20, 10, 95};

size_t size = 3;

cout

cout "

bool ok = removeN(a, size, 2, 1);

cout " "

cout [20], return->true"

}

{

const int CAP = 30;

int a[CAP] = {20, 10, 95};

size_t size = 3;

cout

cout "

bool ok = removeN(a, size, 3, 1);

cout " "

cout [20, 10, 95], return->false"

}

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();

}

6 THE removeN PROBLEM Write the function removeN() which removes "N" elements from the array starting at a given position. Here is an example where we remove 3 elements, starting at position 2. int a[50] 10, 54, 81, 45, 95, 25, 10, 95}; size size - 8; bool ok removeN(a, size, 3, 2); t The function takes four parameters: the array and its effective size, which may both be modified, along with the number of elements to remove and the position to start removing. (Be careful with these, that you don't reverse them.) The function returns true if it succeeds and false otherwise. It can fail if there are not N elements remaining (measured from the starting position), or, if position is out of bounds

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!