Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is due tonight at 11:59. Please show you steps and add comments as to how you came up with the idea for the array

image text in transcribedimage text in transcribedThis is due tonight at 11:59. Please show you steps and add comments as to how you came up with the idea for the array memory storage! Thank you very much. Make sure it is written in c++.

Program Description You need to write a C++ program to implement a variable length 2-dimension array of integer. You can think about a 2-dimension array is an array of arrays as illustrated in Figure 1. I want you to dynamically allocate the memory for the second dimension arrays (for each row). Figure 1: Example of a 2-dimension array Your program should allow the user to query the elements of this data struc- ture by providing two values (indices of the arrays) where the first number indi- cates the row and the second number indicates the column. Also, your program should prompt the user if the input is out of bound. For instance, if the structure has 3 rows, the user input of 3 should return an out of bound error (remember that the indices start from 0 and hence, 3 rows would have indices 0, 1, and 2 The same boundary check should be applied for each row. For instance, if a row has size 4, the user input 6 should have out of bound prompt for user. It is a good practice to print out the memory addresses to better understand the memory allocation Input To build such a 2-dimension array, you need to get the dimension and input information from a file named "input.txt". The "input.txt" file has the fol- lowing format, and generates a 2-dimension array as shown in Figure 2: 3 12 5 9 12 11 7 1390 12 2 21 8 8 16 0 12 21 16 Figure 2: Example of a 2-dimension array. he first number in the input indicates the number of rows (number of horizontal arrays that should be defined dynamically). After that the first row, you will have a row of one number indicating the size of each row following by the element of that row. Output When the structure is populated, you should allow the user to query the ele- ments. In the above example, query 0 0 should return 5 and query 3 1 should return 8. Meanwhile, queries 3 4 and 4 1 should prompt out of bound. The program should terminate with the user input -1-1. Be careful to release the allocated memory

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

Privacy In Statistical Databases International Conference Psd 2022 Paris France September 21 23 2022 Proceedings Lncs 13463

Authors: Josep Domingo-Ferrer ,Maryline Laurent

1st Edition

3031139445, 978-3031139444

More Books

Students also viewed these Databases questions

Question

2. What is the impact of information systems on organizations?

Answered: 1 week ago

Question

Evaluate the impact of technology on HR employee services.

Answered: 1 week ago