Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this question, you will write four versions of a function getPosNums that gets an array of integers arr, and its logical size. When called

In this question, you will write four versions of a function getPosNums 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* getPosNums1(int* arr, int arrSize, int& outPosArrSize)

returns the base address of the array (containing the positive numbers), and updates the output parameter outPosArrSize with the arrays logical size.

b) void getPosNums2(int* arr, int arrSize, int*& outPosArr, int& outPosArrSize)

updates the output parameter outPosArr with the base address of the array (containing the positive numbers), and the output parameter outPosArrSize with the arrays logical size.

c) int* getPosNums3(int* arr, int arrSize, int* outPosArrSizePtr) returns the base address of the array (containing the positive numbers), and uses the pointer outPosArrSizePtr to update the arrays logical size.

d) void getPosNums4(int* arr, int arrSize, int** outPosArrPtr, int* outPosArrSizePtr)

uses the pointer outPosArrPtr to update the base address of the array (containing the positive numbers), and the pointer outPosArrSizePtr to update the arrays logical size.

Note: You should also write a program that calls and tests all these functions.

In C++

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

More Books

Students also viewed these Databases questions

Question

What are your strengths? Weaknesses?

Answered: 1 week ago