Answer to Question #217468 in C++ for PlsCompleteTheCode

Question #217468

Use dynamic list to declare array of 10 integers, then write the following function:

(show the output for each function)

1-   Insert an integer at the beginning of the array

2-   Delete the last element of the array

1
Expert's answer
2021-07-15T01:54:01-0400
/******************************************************************************
Use dynamic list to declare array of 10 integers, then write the following function:


(show the output for each function)
1-   Insert an integer at the beginning of the array
2-   Delete the last element of the array
*******************************************************************************/


#include <iostream>


using namespace std;


void insert(int arr[],int n){
    arr[0]=n;
}


void ldelete(int arr[],int n){
    int **x = new int* [n]; 
    for ( int i = 0; i < n; i++ ) {
        x[i] = new int (i+10);
    }


    delete x[n-1]; 
    x[n-1] = nullptr;
    for ( int i = 0; i < n; i++ ) {
        delete x[i]; 
    }
    delete[] x; 
}
int main()
{
    
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS