Professional Documents
Culture Documents
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
class node
{
public:
int data;
node *next;
};
class SLL
{
node *head;
public:
SLL()
{
head=NULL;
}
void Insert_beg();
void Insert_mid();
void Insert_end();
void Delete_beg();
void Delete_mid();
void Delete_end();
void Display();
};
}
void SLL :: Insert_beg()
{
node *p,*temp=head;
P=new Node;
cout<<"Enter Data For The New Node : ";
cin>>x;
p->data=x;
p->next=NULL;
if(head==NULL)
{
head=p;
}
else
{
p->Next=head;
head=p;
}
}
int main()
{
SLL L;
int ch;
clrscr();
while(1)
{
cout<<"CHOICE OPERATION\n";
cout<<" 1 Insert at begining \n";
cout<<" 2 Insert at end \n";
cout<<" 3 Insert in middle \n";
cout<<" 4 deltion from begining \n";
cout<<" 5 deltion from end \n";
cout<<" 6 deltion from middle \n";
cout<<" 7 Exit\n";
cout<<"Enter Your Choice : ";
cin>>ch;
switch(ch)
{
case 1: L.Insert_beg();
break;
case 2: L.Insert_end();
break;
case 3: L.Insert_mid();
break;
case 4: L.Delete_beg();
break;
case 5: L.Delete_end();
break;
case 6: L.Delete_mid();
break;
case 7: exit(0);
default: cout<<"Wrong Choice\n";
}
}
return 0;
}
}