Lab Section: e.g. CP107-[1 2]-[A B C] Lab Assignment: Lab9 Pointers & StructsProject
Name: Lab9_1 Array Builder Description: Dynamically allocates a new integer array or larger integer arrayLimitations:Credits:
Includes mandatory file header:- uses empty Win32 Console Application:- Programs submitted with correct folder structure and correct files (cpp & h):user Interface (10%):———————- Clean easy-to-use:- Informed user of application:- Prompted user for input data:- Leaves cursor at end of line prompting input:- Correct spelling in user interface: Source Code Formatting (40%):—————————— Descriptive Names for functions and variables:- Correct Use of Indentations:- Effective use of newlines:- Use of local variables:- Misuse of global variables:- Effective use of comments:- Use of constants and enums:Demo Results (40%):——————– Compiles w/o errors:- Instructor pause included in all return paths:- Input validation done according to requirements:- Produced expected program output:- <program spectific>Test Coverage (5%):——————– Program output included:- Boundary conditions tested:*/#include <iostream>
using namespace std;int * arrayBuilder(int * arr, int size, int newSize);void showArray(int * arr, int size);int main(){int * theArray = 0;int i;cout << “This program demonstrates an array builder function.” << endl << endl;// create the initial array. The initial size is zero and the requested size is 5.theArray = arrayBuilder(theArray, 0, 5);// show the array before values are addedcout << “theArray after first call to builder: ” << endl;showArray(theArray, 5);// add some values to the arrayfor(int i = 0; i < 5; i++){theArray[i] = i + 100;}// show the array with added valuescout << endl << “Some values stored in the array: ” << endl;showArray(theArray, 5);// expand the size of the array. size is not the original size. newSize// must be greater than size.theArray = arrayBuilder(theArray, 5, 10);// show the new array with the new sizecout << endl << “The new array: ” << endl;showArray(theArray, 10);cout << endl;delete [] theArray; // be sure to do this a1t the end of your program!system(“pause”);return 0;}/*FUNCTION: arrayBuilderINPUTS: Pointer to an array. Size of the array. If size is zero, arr can be NULL.
Size of the new array.OUTPUTS: Returns a pointer to allocated memory. If newSize is greater than size, an array of newSize is allocated and the old array is copied into the new array. Memory pointed to by the old array is deleted. All new elements are initialized to zero.*/int * arrayBuilder(int * arr, int size, int newSize){// TODO: Your code goes here// HINT: Design the function before writing it.return NULL; // default return value. No memory allocated!}/*FUNCTION: showArrayINPUTS: Pointer to an array. Size of the array. If size is zero, arr can be NULL.OUTPUTS: Prints the contents of the array to the console.*/void showArray(int * arr, int size){cout << “arr = “;for(int i = 0; i < size; i++){cout << arr[i] << ” “;}cout << endl;}
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more