LIST ADT USING ARRAY

 #include<iostream>

using namespace std;

void create();

void insert();

void deletion();

void search();

void display();

int a,b[20],n,d,e,f,i;

int main()

{

int c;

cout<<"\n Main Menu";

cout<<"\n 1.Create \n 2.Delete \n 3.Search \n 4.insert \n 5.Display \n 6.Exit";

do

{

cout<<"\n enter your choice:";

cin>>c;

switch(c)

{

case 1: create(); break;

case 2: deletion(); break;

case 3: search(); break;

case 4: insert(); break;

case 5: display(); break;

case 6: exit(0); break;

default:

cout<<"The given number is not between 1-5\n";

}

}

while(c<=6);

return 0;

}

void create()

{

cout<<"\n Enter the number of elements you want to create: ";

cin>>n;

cout<<"\nenter the elements\n";

for(i=0;i<n;i++)

{

cin>>b[i];

}

}

void deletion()

{

cout<<"Enter the number u want to delete \n";

cin>>d;

for(i=0;i<n;i++)

{

if(b[i]==d)

{

b[i]=0;

cout<<d<<" deleted";

}

}

}

void search()

{

cout<<"Enter the number \n";

cin>>e;

for(i=0;i<n;i++)

{

if(b[i]==e)

{

cout<<"Value found the position\n"<<i+1;

}

}

void insert()

{

cout<<"\nenter how many number u want to insert: ";

cin>>f;

cout<<"\nEnter the elements\n";

for(i=0;i<f;i++)

{

cin>>b[n++];

}

}

void display()

{

for(i=0;i<n;i++)

{

cout<<"\n"<<b[i];

}

}

Comments

  1. // Online C++ compiler to run C++ program online
    #include
    using namespace std;
    void create();
    void insert();
    void deletion();
    void search();
    void display();
    int a,b[100],n,d,e,f,i;
    int main()
    {
    int c;
    cout<<"/n MAIN MENU";
    cout<<"\n 1- CREATE \n2-DELETE \n3-SEARCH \n 4-INSERT \n 5-UPDATE";
    do
    {
    cout<<"\n Enter your choice";
    cin>>c;
    switch(c)
    {
    case 1:create();break;
    case 2:deletion();break;
    case 3:search();break;
    case 4:insert();break;
    case 5:display();break;
    default:
    cout<<"given number is invalid";
    }
    }
    while(c<=6);
    return 0;
    }
    void create()
    {
    cout<<"\nEnter the elements u need to create";
    cin>>n;
    cout<<"\n Enter the elements";
    for(i=0;i>b[i];
    }
    }
    void deletion()
    {
    cout<<"\n Enter the lemetns to delete";
    cin>>d;
    for(i=0;i>e;
    for(i=0;i>f;
    cout<<"\nenter the lemtns";
    for(i=0;i>b[n++];
    }
    }
    void display()
    {
    for(i=0;i<n;i++)
    {
    cout<<"\n"<<b[i];
    }
    }

    ReplyDelete

Post a Comment

Popular posts from this blog

LIST ADT USING LINKED LIST

CLASSES CREATION

SORTING PROGRAM