queue operations using linked list
C program for queue operations using linked list.
#include<stdio.h>
#include<malloc.h>
#define MAXSIZE 10
void insertion();
void deletion();
void display();
struct node
{
int info;
struct node *link;
}*new,*temp,*p,*front=NULL,*rear=NULL;
typedef struct node N;
main()
{
int ch;
do
{
printf("\n\t\t\tLinked queue");
printf("\n 1.Insertion");
printf("\n 2.Deletion");
printf("\n 3.Display");
printf("\n 4.Exit");
printf("\n Enter your choice : ");
scanf("%d",&ch);
switch(ch)
{
case 1:
insertion();
break;
case 2:
deletion();
break;
case 3:
display();
break;
default:
break;
}
}while(ch<=3);
}
void insertion()
{
int item;
new=(N*)malloc(sizeof(N));
printf("\nEnter the item : ");
scanf("%d",&item);
new->info=item;
new->link=NULL;
if(front==NULL)
front=new;
else
rear->link=new;
rear=new;
}
void deletion()
{
if(front==NULL)
printf("\nQueue is empty");
else
{
p=front;
printf("\nDeleted element is : %d",p->info);
front=front->link;
free(p);
}
}
void display()
{
if(front==NULL)
printf("\nQueue is empty");
else
{
printf("\nThe elements are : ");
temp=front;
while(temp!=NULL)
{
printf("%d",temp->info);
temp=temp->link;
}
}
}
Keys : linked list, queue, queue operations using linked list, queue using linked list, "c linked" list introduction, linked implimentation of stack in c language, program of implimentation of stack in linked lists in c language, singile linkedlists in c, single linkedlists in c, c linked list.
queue operations using linked list,

Mistake in code
in insertion function
if front==NULL
with front=p
rear also assign to p;
else wrong output
means
if(front==NULL)
{
front=p;
rear=p
}
it is dealt with at the end already. See the program closely. Its correct.
its very good
& tanx for your nice web
It’s very useful to all.
isnt this suppose to be for stack implementation? Last in First out???
I had a few errors running this program on my pc..here’s the corrected code with a few corrections from my side..
#include
#include
#define MAXSIZE 10
void insertion();
void deletion();
void display();
typedef struct node
{
int info;
node *link;
}N;
N *new1,*temp,*p,*front=NULL,*rear=NULL;
void main()
{
int ch;
do
{
printf(“\n Enter your choice : “);
printf(“1.Insertion 2.Deletion 3.Display 4.Exit”);
scanf(“%d”,&ch);
switch(ch)
{
case 1:insertion();break;
case 2:deletion();break;
case 3:display();break;
case 4:
default:break;
}
}while(chinfo=item;
new1->link=NULL;
if(front==NULL)
front=new1;
else
rear->link=new1;
rear=new1;
}
void deletion()
{
if(front==NULL)
printf(“\nQueue is empty”);
else
{
p=front;
printf(“\nDeleted element is : %d”,p->info);
front=front->link;
free(p);
}
}
void display()
{
if(front==NULL)
printf(“\nQueue is empty”);
else
{
printf(“\nThe elements are : “);
temp=front;
while(temp!=NULL)
{
printf(“%d “,temp->info);
temp=temp->link;
}
}
}
i am very thankful 2 u for this program. u r very good programmer… this program is very easy to understand…. thanks….
thanxx dude, very very THANK U, tomorrow my practical exams of Data Structures & Algo. (DSA), i get my problem’s solution here so ONCE MORE THANKSSSSSSSSS
this site provides me excellent codes with good logic