Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USE C++ AND Solve all 3 parts as they are related (a): In this task we consider ptr as a 2D matrix. Whereas, number of

USE C++ AND Solve all 3 parts as they are related

image text in transcribed

(a): In this task we consider ptr as a 2D matrix. Whereas, number of rows would be fixed but make number of columns variables. To do this, instead of using arrays of fixed column size allocated on stack, you will make each element of array to have nColumns (passed as argument to the function) elements and store them on heap using new operator. Next, initialize the values of these arrays randomly using for loop and ptr. Finally display the sum of each individual array. You are not allowed to access the array using original variable name. (b): In the previous task we make number of columns of a 2D matrix variables. Here we will make number of rows variables as well. Thus we will have a way of defining a generic 2D matrix according to user choice. Now your goal is to write a function that receives three arguments: (i) an alias to a 2D pointer; (ii)number of rows; and (iii) number of columns, Now your goal is to first allocate the memory for rows and then for columns dynamically using new operator. (c): In this function, your goal is to write code for deallocating a dynamically allocated 2D matrix. Your function will receive three arguments: (i) a 2D pointer; (ii) number of rows; and (iii) number of columns. Complete the code to properly deallocate

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

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago