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 adorn. Prompt the interpretation ce the extent of the adorn and gorge it in with esteems. You are also asked to tool the coercionthcoming 3 exercises: envelop addEsteem (double* arr in, int& extent, envelop novelValue); This exercises produces a novel adorn with extent+1, copies pristine adorn esteems and affix the novel esteem entered by the interpretationr. The novel adorn is then produceed to the deep exercise envelop* deleteEsteem (double* arr in, int& extent, envelop deleteValue); This exercise produces a novel adorn with extent-1, copies pristine adorn esteems exclude ce the esteem to be deleted (delete Esteem). You can wear that the adorn contains singular esteem. Also voice that if delete Esteem does referable rest in the initiatory adorn then the exercise earn barely produce the initiatory adorn as is. unsubstantial printArr (envelop arr_in, int extent) This exercise prints quenched the esteem of an adorn Here is an development deep exercise (incomplete): unsubstantial deep () int extent; envelop* arr_in; //read extent and produce adorn
    media%2F9b0%2F9b018115-7899-41ff-b1b2-b8

    00 etisalat令 12:31 AM 34% EO HW1 Write a C+ program that produces a dynamic 1D adorn. Prompt the interpretation ce the extent of the adorn and gorge it in with esteems. You are also asked to tool the coercionthcoming 3 exercises: envelop addEsteem (double* arr in, int& extent, envelop novelValue); This exercises produces a novel adorn with extent+1, copies pristine adorn esteems and affix the novel esteem entered by the interpretationr. The novel adorn is then produceed to the deep exercise envelop* deleteEsteem (double* arr in, int& extent, envelop deleteValue); This exercise produces a novel adorn with extent-1, copies pristine adorn esteems exclude ce the esteem to be deleted (delete Esteem). You can wear that the adorn contains singular esteem. Also voice that if “delete Esteem” does referable rest in the initiatory adorn then the exercise earn barely produce the initiatory adorn as is. unsubstantial printArr (envelop arr_in, int extent) This exercise prints quenched the esteem of an adorn Here is an development deep exercise (incomplete): unsubstantial deep () int extent; envelop* arr_in; //read extent and produce adorn

    Expert Acceptance

     

    #include <iostream>
    #include <string>
    using namespace std;
    unsubstantial printArr(envelop *arr_in, int extent){

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

    envelop *arr_novel = (envelop *)malloc((size+1)*sizeof(double));

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

    extent = extent + 1;
    produce arr_new;
    }

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

    envelop *arr_novel = (envelop *)malloc((size-1)*sizeof(double));
    bool faint = true;
    for(int i=0;i<size;++i){
    if(arr_in[i]==deleteValue){
    faint = 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];
    }
    extent = extent – 1;
    produce arr_new;
    }

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

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

    }

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

    Thanks, allow me understand if there is any affair.