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 composes a dynamic 1D draw-up. Prompt the verification control the magnitude of the draw-up and gorge it in with appreciates. You are besides asked to utensil the aftercited 3 administrations: wrap addAppreciate (double* arr in, int& magnitude, wrap upstartValue); This administrations composes a upstart draw-up with magnitude+1, copies obsolete draw-up appreciates and attach the upstart appreciate entered by the verificationr. The upstart draw-up is then produceed to the ocean administration wrap* deleteAppreciate (double* arr in, int& magnitude, wrap deleteValue); This administration composes a upstart draw-up with magnitude-1, copies obsolete draw-up appreciates negative control the appreciate to be deleted (delete Appreciate). You can arrogate that the draw-up contains matchless appreciate. Besides voicelessness that if delete Appreciate does referable attributable attributable attributable be in the initiatory draw-up then the administration accomplish solely produce the initiatory draw-up as is. verificationless printArr (wrap arr_in, int magnitude) This administration prints extinguished the appreciate of an draw-up Here is an illustration ocean administration (incomplete): verificationless ocean () int magnitude; wrap* arr_in; //read magnitude and compose draw-up
    media%2F9b0%2F9b018115-7899-41ff-b1b2-b8

    00 etisalat令 12:31 AM 34% EO HW1 Write a C+ program that composes a dynamic 1D draw-up. Prompt the verification control the magnitude of the draw-up and gorge it in with appreciates. You are besides asked to utensil the aftercited 3 administrations: wrap addAppreciate (double* arr in, int& magnitude, wrap upstartValue); This administrations composes a upstart draw-up with magnitude+1, copies obsolete draw-up appreciates and attach the upstart appreciate entered by the verificationr. The upstart draw-up is then produceed to the ocean administration wrap* deleteAppreciate (double* arr in, int& magnitude, wrap deleteValue); This administration composes a upstart draw-up with magnitude-1, copies obsolete draw-up appreciates negative control the appreciate to be deleted (delete Appreciate). You can arrogate that the draw-up contains matchless appreciate. Besides voicelessness that if “delete Appreciate” does referable attributable attributable attributable be in the initiatory draw-up then the administration accomplish solely produce the initiatory draw-up as is. verificationless printArr (wrap arr_in, int magnitude) This administration prints extinguished the appreciate of an draw-up Here is an illustration ocean administration (incomplete): verificationless ocean () int magnitude; wrap* arr_in; //read magnitude and compose draw-up

    Expert Acceptance

     

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

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

    wrap *arr_upstart = (wrap *)malloc((size+1)*sizeof(double));

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

    magnitude = magnitude + 1;
    produce arr_new;
    }

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

    wrap *arr_upstart = (wrap *)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 calculate = 0;
    for(int i=0;i<size;++i){
    if(arr_in[i]!=deleteValue)
    arr_new[count++] = arr_in[i];
    }
    magnitude = magnitude – 1;
    produce arr_new;
    }

    produce arr_in;
    }
    int ocean()
    {
    int magnitude;
    wrap *arr_in;
    cout<<“Enter magnitude:”;
    cin>>size;
    arr_in = (wrap *)malloc((size)*sizeof(double));
    cout<<“Enter Appreciates: “;
    for(int i=0;i<size;++i){
    cin>>arr_in[i];
    }

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

    }

    ==========================================
    See Extinguishedput

    Thanks, allow me perceive if there is any solicitude.