Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write the function catReven() which concatenates (appends) all the even numbers of the source array to the destination array, in reversed order. We are currently

Write the function catReven() which concatenates (appends) all the even numbers of the source array to the destination array, in reversed order.

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.image text in transcribed

/**

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 src[CAP] = {1, 2, 3, 4, 5, 6};

int dest[CAP] = {98, 45, 18, 72};

size_t dSize = 4;

cout

cout "

cout "

bool ok = catReven(dest, dSize, CAP, src, 6);

cout " "

cout [98, 45, 18, 72, 6, 4, 2], return->true"

}

{

const int CAP = 5;

int src[CAP] = {2, 3, 4};

int dest[CAP] = {98, 45, 18, 72};

size_t dSize = 4;

cout

cout "

cout "

bool ok = catReven(dest, dSize, CAP, src, 3);

cout " "

cout [98, 45, 18, 72], return->false"

}

{

const int CAP = 5;

int src[CAP] = {};

int dest[CAP] = {98, 45, 18, 72};

size_t dSize = 4;

cout

cout "

cout "

bool ok = catReven(dest, dSize, CAP, src, 0);

cout " "

cout [98, 45, 18, 72], 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();

}

7 THE catReven PROBLEM Write the function catReven() which concatenates (appends) all the even numbers of the source array to the destination array, in reversed order. Here's a short example: int src[50]-1, 2, 3, 4, 5, 6]; int dest[50]98, 45, 18, 72); size t dSize - 4; bol o catReven(dest, dSize, 50, src, 6); As you can see the function takes 5 arguments: The destination array and its size, which may both be modified. .The destination capacity, the source array and the source size, which are not modified. In the example shown dSize would be changed to 7 and the destination array would contain (98, 45, 18, 72, 6, 4, 2). The function returns true if successful and false if the destination array does not have the space to add the new elements, or if the source array is empty

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions

Question

Name the criteria of the EFQM Excellence Model.

Answered: 1 week ago