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

Prakhar Singh: Queue Using Link List

The document describes a C program that implements a queue using a linked list. The program contains functions to create, insert, delete and display elements in the queue. The main function uses a switch case to allow the user to select these queue operations and displays the current state after each operation.

Uploaded by

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

Prakhar Singh: Queue Using Link List

The document describes a C program that implements a queue using a linked list. The program contains functions to create, insert, delete and display elements in the queue. The main function uses a switch case to allow the user to select these queue operations and displays the current state after each operation.

Uploaded by

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

QUEUE USING LINK LIST

(11BEC1108)

PRAKHAR SINGH
#include<stdio.h>

#include<conio.h>

#include<stdlib.h>

struct node

int data;

struct node *link;

};

struct node *cur,*first,*last;

void create();

void insert();

void delte();

void display();

void create()

printf("\nENTER THE FIRST ELEMENT: ");

cur=(struct node *)malloc(sizeof(struct node));

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

cur->link=NULL;

first=cur;
last=cur;

void insert()

printf("\nENTER THE NEXT ELEMENT: ");

cur=(struct node *)malloc(sizeof(struct node));

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

cur->link=NULL;

last->link=cur;

last=cur;

void delte()

if(first==NULL)

printf("\t\nQUEUE IS EMPTY\n");

else

cur=first;

first=first->link;

cur->link=NULL;

printf("\n DELETED ELEMENT IS %d\n",cur->data);

free(cur);

}
}

void display()

cur=first;

printf("\n");

while(cur!=NULL)

printf("\t%d",cur->data);

cur=cur->link;

int main()

int ch;

while(1)

printf("\n\n 1.CREATE \n 2.INSERT \n 3.DELETE \n 4.EXIT \n");

printf("\nENTER YOUR CHOICE : ");

scanf("%d",&ch);

switch(ch)

case 1:

create();
display();

break;

case 2:

insert();

display();

break;

case 3:

delte();

display();

break;

case 4:

exit(0);

You might also like