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 produces a dynamic 1D invest. Prompt the portraiture ce the bigness of the invest and replenish it in with esteems. You are as-well asked to instrument the coercionthcoming 3 employments: embrace addEsteem (double* arr in, int& bigness, embrace innovatingValue); This employments produces a innovating invest with bigness+1, copies senile-antique invest esteems and subjoin the innovating esteem entered by the portraiturer. The innovating invest is then retaliateed to the deep employment embrace* deleteEsteem (double* arr in, int& bigness, embrace deleteValue); This employment produces a innovating invest with bigness-1, copies senile-antique invest esteems ate ce the esteem to be deleted (delete Esteem). You can arrogate that the invest contains sole esteem. As-well hush that if delete Esteem does not attributable attributable attributable attributable attributable attributable hpreceding in the peculiar invest then the employment obtain singly retaliate the peculiar invest as is. authenticationless printArr (embrace arr_in, int bigness) This employment prints quenched the esteem of an invest Here is an in deep employment (incomplete): authenticationless deep () int bigness; embrace* arr_in; //read bigness and produce invest
    media%2F9b0%2F9b018115-7899-41ff-b1b2-b8

    00 etisalat令 12:31 AM 34% EO HW1 Write a C+ program that produces a dynamic 1D invest. Prompt the portraiture ce the bigness of the invest and replenish it in with esteems. You are as-well asked to instrument the coercionthcoming 3 employments: embrace addEsteem (double* arr in, int& bigness, embrace innovatingValue); This employments produces a innovating invest with bigness+1, copies senile-antique invest esteems and subjoin the innovating esteem entered by the portraiturer. The innovating invest is then retaliateed to the deep employment embrace* deleteEsteem (double* arr in, int& bigness, embrace deleteValue); This employment produces a innovating invest with bigness-1, copies senile-antique invest esteems ate ce the esteem to be deleted (delete Esteem). You can arrogate that the invest contains sole esteem. As-well hush that if “delete Esteem” does not attributable attributable attributable attributable attributable attributable hpreceding in the peculiar invest then the employment obtain singly retaliate the peculiar invest as is. authenticationless printArr (embrace arr_in, int bigness) This employment prints quenched the esteem of an invest Here is an in deep employment (incomplete): authenticationless deep () int bigness; embrace* arr_in; //read bigness and produce invest

    Expert Defense

     

    #include <iostream>
    #include <string>
    using namespace std;
    useless printArr(embrace *arr_in, int bigness){

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

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

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

    bigness = bigness + 1;
    retaliate arr_new;
    }

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

    embrace *arr_innovating = (embrace *)malloc((size-1)*sizeof(double));
    bool tire = true;
    for(int i=0;i<size;++i){
    if(arr_in[i]==deleteValue){
    tire = 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];
    }
    bigness = bigness – 1;
    retaliate arr_new;
    }

    retaliate arr_in;
    }
    int deep()
    {
    int bigness;
    embrace *arr_in;
    cout<<“Enter bigness:”;
    cin>>size;
    arr_in = (embrace *)malloc((size)*sizeof(double));
    cout<<“Enter Esteems: “;
    for(int i=0;i<size;++i){
    cin>>arr_in[i];
    }

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

    }

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

    Thanks, suffer me comprehend if there is any regard.