Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/** CS 150 PARTIALLY FILLED ARRAYS Follow the instructions on your handout to complete the requested function. You may not use any library functions or

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 ///////////////////////

///////////////// 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],2, 3, 4, 5, 6); int dest[50]98, 45, 18, 72); size t dSize - 4; bool okcatReven (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

Step: 3

blur-text-image

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

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

ISBN: 1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago