#include<stdio.h>
#include<conio.h>
void main()
{
 int ch,x,i,head=NULL;
 void create()
 clrscr();

 while(1)
 {
  printf("\n 1.Create\n2.Insert\n3.Delete\n4.Display\n5.Search\n6.Reverse\n");
  printf("7.Exit");
  printf("Click your choice  ");
  scanf("%d",&ch);
  if(ch==7) break;
  switch(ch)
  {
   case 1:create(); break;
   case 2:display();
	 printf("\nEnter elements and its locations:");
	 scanf("%d%d", &x,&i);
	 insert(x,i);  break;
   case 3:if(head==NULL)  printf("\nlinked list is empty");
	 else
	 {
	  display();
	  printf("\nDeleted element is %d", delete(i));
	 }
	 getch();  break;
   case 4:display(); getch(); break;
   case 5:if(head==NULL)  printf("Empty list");
	 else
	 {
	  printf("Enter the element to be searched:");
	  scanf("%d", &x);
	  if(search(x))  printf("\n Element found!");
	  else  printf("\n Element not found");
	 }  getch();  break;
   case 6:reverse();  display();  getch();
  }
 }
 int delete(int x)
 {
  int i,y,p=head;
  if(x==1)  {y=p->info; head=p->next; }
  else
  {
   q=NULL;
   for(i=1;i<x;i++)
   { q=p;p=p->next;q->next=p->next;y=p->info;
  }
  free(p); return(y);
 }

 void makeempty()
 {
  while(head!=NULL)
  { p=head; head=head->next; free(p); }
 }





