Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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 functions

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

Database Systems For Advanced Applications 27th International Conference Dasfaa 2022 Virtual Event April 11 14 2022 Proceedings Part 2 Lncs 13246

Authors: Arnab Bhattacharya ,Janice Lee Mong Li ,Divyakant Agrawal ,P. Krishna Reddy ,Mukesh Mohania ,Anirban Mondal ,Vikram Goyal ,Rage Uday Kiran

1st Edition

3031001257, 978-3031001253

More Books

Students also viewed these Databases questions