Answer to Question #265535 in C++ for Roe

Question #265535

Write the array implementation of a list.


Requirements:


1)create class


2)No global declarations


3) functions


Isempty()


Delete()


Insert()


Display()


4)Call the functions in main

1
Expert's answer
2021-11-13T23:52:50-0500
#include <iostream>
using namespace std;


int a,arr[20],n,e;
void Delete()
{
    int n;
    cout<<"\nEnter element to delete:\n";
    cin>>n;
    for(int i=0;i<n;i++)
    {
    if(arr[i]==n)
    {
    arr[i]=0;
    cout<<n<<" deleted";
    }
    }
}
void create()
{
    cout<<"\n Enter the number of elements to create: "; cin>>n;
    cout<<"\nEnter the elements\n";
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
}


void display(){
    for(int i=0;i<n;i++)
    {
    cout<<"\n"<<arr[i];
    }
}
void insert()
{
    int n;
    cout<<"\nEnter number of elements to insert: ";
    cin>>n;
    cout<<"\nEnter the elements\n";
    for(int i=0;i<n;i++){
        cin>>arr[n++];
    }
}




int main()
{
    int c;
    cout<<"\n1. Create \n2. Delete \n3. Insert \n4. Display \n5. Exit";
    do
    {
    cout<<"\nEnter your choice:";
    cin>>c;
    switch(c)
    {
        case 1: 
            create(); 
            break;
        case 2: 
            Delete(); 
            break;
        case 3: 
            insert(); 
            break;
        case 4: 
            display(); 
            break;
        case 5: 
            exit(0); 
            break;
        default:
            cout<<"Invalid Input\n";
    }
    }
    while(c<=6);
    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