Thursday, December 18, 2014

Implement Queue Using Link List in c

#include<stdio.h>
#include<stdlib.h>
#include "QUEUE.h"  //given before
int main()
{
struct node *s1=NULL,*s2=NULL;
int choice ,item;
while(1)

{
printf("\n1.Insert\n");
printf("2. Delete\n");
printf("3. Display the element at the front\n");
printf("4. Display all element of the queue\n");
printf("5. Quit\n");
printf("Enter your choice\n");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("Input the element for adding in queue:");
scanf("%d",&item);
insert(&s1,&s2,item);
break;
case 2:
printf("deleted item is %d",del(&s2));
break;
case 3:
printf("Element at the front of Queue is %d\n",peek(s2));
break;
case 4:
display(s2);
break;
case 5:
exit(1);
}
}
return 0;
}