#include // size_t for sizes and indexes using namespace std; ///////||/ WRITE YOUR FUNCTION BELOW THIS LINE //// //////// int appendEvens(const int al[], int a2[], size_t sizel, size_t& size2) { int result; // Add your code here return result; }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

C++

Can someone help me with this problem? I have been trying it but it still doesn't work. 

Thank you

1
#include <cstddef> // size t for sizes and indexes
2
using namespace std;
3
4
/////// WRITE YOUR FUNCTION BELOW THIS LINE
///
int appendEvens (const int a1[], int a2[], size_t sizel, size_t& size2)
7
int result;
// Add your code here
return result;
}
9.
10
11
CodeCheck
Reset
Testers
Running Tester.cpp
fail fail fail fail fail fail fail fail fail fail pass pass fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail
Testing Append Evens
appendEvens ( [21, 38, 32, 49, 12, 35, 45, 52], [], sizeA, sizeB)->
Returned: 0
Expected: 4
Array: []
Expected: [38, 32, 12, 52]
Size: 0
Expected: 4
Transcribed Image Text:1 #include <cstddef> // size t for sizes and indexes 2 using namespace std; 3 4 /////// WRITE YOUR FUNCTION BELOW THIS LINE /// int appendEvens (const int a1[], int a2[], size_t sizel, size_t& size2) 7 int result; // Add your code here return result; } 9. 10 11 CodeCheck Reset Testers Running Tester.cpp fail fail fail fail fail fail fail fail fail fail pass pass fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail fail Testing Append Evens appendEvens ( [21, 38, 32, 49, 12, 35, 45, 52], [], sizeA, sizeB)-> Returned: 0 Expected: 4 Array: [] Expected: [38, 32, 12, 52] Size: 0 Expected: 4
Write the function appendEvens() which, given two arrays, adds all of the even elements from the first to the
second. You may assume the second has enough space.
The function takes 4 arguments:
array 1 which may not be modified
array 2 which may be modified
size 1 which is not modified
size 2 with is modified
The function returns the number of items appended, or -1 if the first array is empty.
Here's an example:
const int MAX = 100;
int al[MAX]
int a2[MAX] = {7, 9};
size t size2 =
int appended = appendEvens (al, a2, 3, size2); // 1 appended
// After: size2->3, a2->[7, 9, 2]
{1, 2, 3};
2;
%3D
Transcribed Image Text:Write the function appendEvens() which, given two arrays, adds all of the even elements from the first to the second. You may assume the second has enough space. The function takes 4 arguments: array 1 which may not be modified array 2 which may be modified size 1 which is not modified size 2 with is modified The function returns the number of items appended, or -1 if the first array is empty. Here's an example: const int MAX = 100; int al[MAX] int a2[MAX] = {7, 9}; size t size2 = int appended = appendEvens (al, a2, 3, size2); // 1 appended // After: size2->3, a2->[7, 9, 2] {1, 2, 3}; 2; %3D
Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY