ads circular queue
ads circular queue
struct node
{
int info;
struct node *link;
};
main( )
{
int choice,data,item;
struct node *last=NULL;
while(1)
{
printf("1.Create List\n");
printf("2.Display\n");
printf("3.Add to empty list\n");
printf("4.Add at beginning\n");
printf("5.Add at end\n");
printf("6.Add after \n");
printf("7.Delete\n");
printf("8.Quit\n");
switch(choice)
{
case 1:
last=create_list(last);
break;
case 2:
display(last);
break;
case 3:
printf("Enter the element to be inserted : ");
scanf("%d",&data);
last=addtoempty(last,data);
break;
case 4:
printf("Enter the element to be inserted : ");
scanf("%d",&data);
last=addatbeg(last,data);
break;
case 5:
printf("Enter the element to be inserted : ");
scanf("%d",&data);
last=addatend(last,data);
break;
case 6:
printf("Enter the element to be inserted : ");
scanf("%d",&data);
printf("Enter the element after which to
insert : ");
scanf("%d",&item);
last=addafter(last,data,item);
break;
case 7:
printf("Enter the element to be deleted : ");
scanf("%d",&data);
last=del(last,data);
break;
case 8:
exit(1);
default:
printf("Wrong choice\n");
}/*End of switch*/
}/*End of while*/
}/*End of main( )*/
for(i=2;i<=n;i++)
{
printf("Enter the element to be inserted : ");
scanf("%d",&data);
last=addatend(last,data);
}
return last;
}/*End of create_list()*/