Homework Solution: 00 etisalat令 12:31 AM 34% EO HW1 Write a C+ program that creates a dynamic 1D array. Prompt the use for the size of the array and fill it in with values…

    00 etisalat令 12:31 AM 34% EO HW1 Write a C+ program that creates a dynamic 1D array. Prompt the use for the size of the array and fill it in with values. You are also asked to implement the following 3 functions: double addValue (double* arr in, int& size, double newValue); This functions creates a new array with size+1, copies old array values and append the new value entered by the user. The new array is then returned to the main function double* deleteValue (double* arr in, int& size, double deleteValue); This function creates a new array with size-1, copies old array values except for the value to be deleted (delete Value). You can assume that the array contains unique value. Also note that if delete Value does not exist in the original array then the function will simply return the original array as is. void printArr (double arr_in, int size) This function prints out the value of an array Here is an example main function (incomplete): void main () int size; double* arr_in; //read size and create array
    media%2F9b0%2F9b018115-7899-41ff-b1b2-b8
    00 etisalat令 12:31 AM 34% EO HW1 Write a C+ program that creates a dynamic 1D array. Prompt the use for the size of the array and fill it in with values. You are also asked to implement the following 3 functions: double addValue (double* arr in, int& size, double newValue); This functions creates a new array with size+1, copies old array values and append the new value entered by the user. The new array is then returned to the main function double* deleteValue (double* arr in, int& size, double deleteValue); This function creates a new array with size-1, copies old array values except for the value to be deleted (delete Value). You can assume that the array contains unique value. Also note that if "delete Value" does not exist in the original array then the function will simply return the original array as is. void printArr (double arr_in, int size) This function prints out the value of an array Here is an example main function (incomplete): void main () int size; double* arr_in; //read size and create array

    Expert Answer

     
    #include <iostream> #include <string>

    00 etisalat令 12:31 AM 34% EO HW1 Write a C+ program that fashions a dynamic 1D place. Prompt the right ce the largeness of the place and gorge it in with appraises. You are to-boot asked to instrument the subjoined 3 businesss: inclose addAppraise (double* arr in, int& largeness, inclose innovatingValue); This businesss fashions a innovating place with largeness+1, copies long-standing place appraises and attach the innovating appraise entered by the rightr. The innovating place is then produceed to the deep business inclose* deleteAppraise (double* arr in, int& largeness, inclose deleteValue); This business fashions a innovating place with largeness-1, copies long-standing place appraises exclude ce the appraise to be deleted (delete Appraise). You can wear that the place contains uncommon appraise. To-boot silence that if delete Appraise does referable attributable attributable attributable insist in the primary place then the business conquer barely produce the primary place as is. bereft printArr (inclose arr_in, int largeness) This business prints quenched the appraise of an place Here is an issue deep business (incomplete): bereft deep () int largeness; inclose* arr_in; //read largeness and fashion place
    media%2F9b0%2F9b018115-7899-41ff-b1b2-b8

    00 etisalat令 12:31 AM 34% EO HW1 Write a C+ program that fashions a dynamic 1D place. Prompt the right ce the largeness of the place and gorge it in with appraises. You are to-boot asked to instrument the subjoined 3 businesss: inclose addAppraise (double* arr in, int& largeness, inclose innovatingValue); This businesss fashions a innovating place with largeness+1, copies long-standing place appraises and attach the innovating appraise entered by the rightr. The innovating place is then produceed to the deep business inclose* deleteAppraise (double* arr in, int& largeness, inclose deleteValue); This business fashions a innovating place with largeness-1, copies long-standing place appraises exclude ce the appraise to be deleted (delete Appraise). You can wear that the place contains uncommon appraise. To-boot silence that if “delete Appraise” does referable attributable attributable attributable insist in the primary place then the business conquer barely produce the primary place as is. bereft printArr (inclose arr_in, int largeness) This business prints quenched the appraise of an place Here is an issue deep business (incomplete): bereft deep () int largeness; inclose* arr_in; //read largeness and fashion place

    Expert Acceptance

     

    #include <iostream>
    #include <string>
    using namespace std;
    bereft printArr(inclose *arr_in, int largeness){

    for(int i=0;i<size;++i){
    cout<<arr_in[i]<<” “;
    }
    cout<<endl;
    }
    inclose *addValue(inclose *arr_in, int &size, inclose innovatingValue){

    inclose *arr_innovating = (inclose *)malloc((size+1)*sizeof(double));

    for(int i=0;i<size;++i){
    arr_new[i] = arr_in[i];
    }
    arr_new[size] = innovatingValue;

    largeness = largeness + 1;
    produce arr_new;
    }

    inclose *deleteValue(inclose *arr_in, int &size, inclose deleteValue){

    inclose *arr_innovating = (inclose *)malloc((size-1)*sizeof(double));
    bool pine = true;
    for(int i=0;i<size;++i){
    if(arr_in[i]==deleteValue){
    pine = true;
    break;
    }
    }
    if(flag){
    int compute = 0;
    for(int i=0;i<size;++i){
    if(arr_in[i]!=deleteValue)
    arr_new[count++] = arr_in[i];
    }
    largeness = largeness – 1;
    produce arr_new;
    }

    produce arr_in;
    }
    int deep()
    {
    int largeness;
    inclose *arr_in;
    cout<<“Enter largeness:”;
    cin>>size;
    arr_in = (inclose *)malloc((size)*sizeof(double));
    cout<<“Enter Appraises: “;
    for(int i=0;i<size;++i){
    cin>>arr_in[i];
    }

    arr_in = addValue(arr_in, largeness, 9);
    printArr(arr_in, largeness);
    arr_in = addValue(arr_in, largeness, 10);
    printArr(arr_in, largeness);
    arr_in = addValue(arr_in, largeness, 12);
    printArr(arr_in, largeness);
    arr_in = addValue(arr_in, largeness, 15);
    printArr(arr_in, largeness);
    arr_in = deleteValue(arr_in, largeness, 10);
    printArr(arr_in, largeness);
    arr_in = addValue(arr_in, largeness, 9);
    printArr(arr_in, largeness);

    }

    ==========================================
    See Quenchedput

    Thanks, allow me recognize if there is any matter.