Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a C++ program using dynamic arrays Requirements: create a 1D dynamic array of *ints (must use pointers) create a 2D dynamic array of *ints

Create a C++ program using dynamic arrays

Requirements:

create a 1D dynamic array of *ints (must use pointers) create a 2D dynamic array of *ints [?][2] (must use pointers) dynamically allocate space for the arrays

main() { 1.ask user how many elements in 1D array 2.ask user how many elements in 2D array 3. populate 1D array 4. populate 2D array 5. print 1D array 6. print 2D array 7. delete 1D array 8. delete 2D array

Extra Credit. ask for nxn. if user types 3 it will be 3x3 if 4 it will be 4x4

invalid input forced to 1 row }

int *array1D = NULL; int numElements; = 0; cin >> numElements;

Functions

// dynamically creates an int and prompts the user for the value // and it returns the pointer to this dynamic int.

int* createInt() // returns a pointer { return _______; }

void populate1DArray(1D array) { for loop createInt(); numberOfElements; }

void populate2DArray(2D array) { for loop rows for loop columns createInt(); } D =new *int[numElements]; / make sure numElements is at least 1

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

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions

Question

What advantages does this tactic offer that other tactics do not?

Answered: 1 week ago

Question

What is the timeline for each tactic?

Answered: 1 week ago