Question: Write the function appendEvens() that, given two arrays, add all of the even elements from the first into the second. We are currently working on

Write the function appendEvens() that, given two arrays, add all of the even elements from the first into the second.

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 appendEvens() that, given two arrays, add all of the

/**

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

using namespace std;

void print(const int a[], size_t size);

void studentTests()

{

cout

cout

const size_t CAP = 30; // all arrays have capacity 30

{

cout

int src[CAP] = {301, 310};

unsigned srcSize = 2;

int dest[CAP] = {56, 23, 76, 18, 29, 73, 40, 34, 21};

unsigned destSize = 9;

cout

cout

cout

int status = appendEvens(src, dest, srcSize, destSize);

cout

cout

cout

cout

cout ["

cout

}

{

cout

int src[CAP] = {}; // first array is empty

unsigned srcSize = 0;

int dest[CAP] = {10, 11, 12, 13, 14};

unsigned destSize = 5;

cout

cout

cout

int status = appendEvens(src, dest, srcSize, destSize);

cout

cout

cout

cout

cout ["

cout

}

cout

cout

}

void print(const int a[], size_t size)

{

cout

if (size > 0)

{

cout

for (size_t i = 1; i

cout

}

cout

}

int main()

{

studentTests();

}

2 THE appendEvens PROBLEM Write the function appendEvens() that, given two arrays, add all of the even elements from the first into the second. You may assume the second has enough space. Here's an example: a1[1, 2, 3], a2[7, 9]-> a1[1, 2, 3], a217, 9, 2] The function returns the number of items appended, or -1 if the first array is empty. int status appendEvens(src, dest, srcsize, destsize); = No Change Change 2 THE appendEvens PROBLEM Write the function appendEvens() that, given two arrays, add all of the even elements from the first into the second. You may assume the second has enough space. Here's an example: a1[1, 2, 3], a2[7, 9]-> a1[1, 2, 3], a217, 9, 2] The function returns the number of items appended, or -1 if the first array is empty. int status appendEvens(src, dest, srcsize, destsize); = No Change Change

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!