0% found this document useful (0 votes)
10 views

Stack Linked

The document describes functions to implement a queue using a linked list data structure in C including enqueue, dequeue and display functions. A main function provides a menu to call these functions.

Uploaded by

arjunkp1678
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Stack Linked

The document describes functions to implement a queue using a linked list data structure in C including enqueue, dequeue and display functions. A main function provides a menu to call these functions.

Uploaded by

arjunkp1678
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

#include<stdio.

h>

#include<stdlib.h>

struct Node

int data;

struct Node *link;

};

struct Node *Front=NULL, *Rear=NULL;

void display()

struct Node *temp;

temp=Front;

if(temp==NULL) printf("\nQueue is Empty...");

else

while(temp!=NULL)

printf("%d->",temp->data);

temp=temp->link;

printf("NULL");

void Enqueue()

struct Node *temp,*New;

temp=Rear;

New=(struct Node *)malloc(sizeof(struct Node));


printf("\nEnter Data:");

scanf("%d",&New->data);

New->link=NULL;

if(Rear==NULL)

Rear=New;

Front=New;

else

Rear->link=New;

Rear=New;

display(Front);

void Dequeue()

struct Node *temp;

temp=Front;

if(temp==NULL)

printf("\nQueue is Empty....");

else

Front=Front->link;

free(temp);

display(Front);

}
int main()

int ch;

do

printf("\n*");

printf("\nQueue Using Linked List");

printf("\n*");

printf("\n1. Enqueue");

printf("\n2. Dequeue");

printf("\n3. Display");

printf("\n0. Exit");

printf("\nEnter Ur Choice : ");

scanf("%d",&ch);

switch(ch)

case 1:

Enqueue();

break;

case 2:

Dequeue();

break;

case 3:

display();

break;

case 0:

exit(0);

default:

printf("\nInvalid Option...");
break;

}while(ch!=0);

You might also like