Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions Using the C++ code below, Create a function/method that will increase the size of an array by 2 (double the size). The function/method must

Instructions

Using the C++ code below, Create a function/method that will increase the size of an array by 2 (double the size). The function/method must return a pointer to the new array. Main will create the initial array and pass it to the function/method. The pointer in main will point to the array with the new size. No data should be lost from the array passed in and all the new locations should be set to zero.

#include  using namespace std; int* ExpandArray(int data[], int size) { } int main() { int size = 2; int* values = new int[size]; values[0] = 55; values[1] = 77; for (int index = 0; index < size; index++) { cout << values[index] << endl; } values = ExpandArray(values, size); for (int index = 0; index < size * 2; index++) { cout << values[index] << endl; } delete[] values; return 0; }

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 Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions