Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use c++ and explain code please. Thanks Question 5: In this question, you will write four versions of a function get PosNums that gets an
Use c++ and explain code please. Thanks
Question 5: In this question, you will write four versions of a function get PosNums that gets an array of integers arr, and its logical size. When called it creates a new array containing only the positive numbers from arr. For example, if arr=[3, -1, -3, 0, 6, 4], the functions should create an array containing the following 3 elements: (3, 6, 4], The four versions you should implement differ in the way the output is returned. The prototypes of the functions are: a) int* get PosNums1 (int* arr, int arrSize, int& outPosArrSize) returns the base address of the array (containing the positive numbers), and updates the output parameter out PosArrSize with the array's logical size. b) void getPosNums2 (int* arr, int arrSize, int*& outPosArr, int& out PosArrSize) updates the output parameter outPosArr with the base address of the array (containing the positive numbers), and the output parameter out PosArrSize with the array's logical size. c) int* get PosNums3 (int* arr, int arrSize, int* outPosArrSizePtr) returns the base address of the array (containing the positive numbers), and uses the pointer out PosArrSizePtr to update the array's logical size. d) void getPosNums 4 (int* arr, int arrSize, int** out PosArrPtr, int* out PosArrSizePtr) uses the pointer out PosArrPtr to update the base address of the array (containing the positive numbers), and the pointer out PosArrSizePtr to update the array's logical size. Note: You should also write a program that calls and tests all these functionsStep 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