Showing posts with label Implementation of Queue using Linked List. Show all posts
Showing posts with label Implementation of Queue using Linked List. Show all posts

Thursday, February 12, 2015

Implementation of Queue using Linked List

AIM:
          To write a C program to implement queue using linked list

ALGORITHM:
            Step 1: Start the program.
            Step 2: For queue insertion operation, check for queue overflow
Step 3: If R>=N then print queue overflow else increment rear pointer and insert  
            the element.
Step 4: For queue deletion operation, check for underflow of the queue.
Step 5: If F=0 then print queue underflow else delete the element and increment 
            the front pointer
Step 6: Stop the program.

PROGRAM
#include<stdio.h >
#include<conio.h >
#include<alloc.h >
struct queue
{
int data;
struct queue *next;
};
struct queue *addq(struct queue *front);
struct queue *delq(struct queue *front);
void main()
{
struct queue *front;
int reply,option,data;
clrscr();
front=NULL;
do
{
printf("\n1.addq");
printf("\n2.delq");
printf("\n3.exit");
printf("\nSelect the option");
scanf("%d",&option);