Question
/** CS 150 PARTIALLY FILLED ARRAYS Follow the instructions on your handout to complete the requested function. You may not use any library functions or
/**
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
*/
#include
///////////////// 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 emptyStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started