0% found this document useful (0 votes)
12 views5 pages

Implementaion of Queue

Uploaded by

oldxmonk49
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)
12 views5 pages

Implementaion of Queue

Uploaded by

oldxmonk49
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/ 5

/* SY CSE 2024-25 Name: Akshay Rajendra

Sonwane Roll No: 65 Batch: S4

Program 14= Implementation of Queue using linked list

#include<stdio.h>

#include<conio.h>

struct Node

int data;

struct Node *next;

};

struct Node *front = NULL;

struct Node *rear = NULL;

void insert(int);

void delete();

void display();

void main()

int choice, data;

clrscr();

printf("\n:: Queue Implementation using Linked List ::\n");

while(1)

printf("\n****** MENU ******\n");

printf("1. Insert\n2. Delete\n3. Display\n4. Exit\n");


printf("Enter your choice: ");

scanf("%d",&choice);

switch(choice)

case 1: printf("Enter the data to insert: ");

scanf("%d", &data);

insert(data);

break;

case 2: delete();

break;

case 3: display();

break;

case 4: exit(0);

default: printf("\nWrong choice..!! Try again!!!\n");

void insert(int data)

struct Node *newNode;

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

newNode->data = data;

newNode -> next = NULL;

if(front == NULL)
front = rear = newNode;

else

rear -> next = newNode;

rear = newNode;

printf("\nInsertion is successfull..!!\n");

void delete()

if(front == NULL)

printf("\nQueue is Empty!!!\n");

else

struct Node *temp = front;

front = front -> next;

printf("\nDeleted element: %d\n", temp->data);

free(temp);

void display()

if(front == NULL)

printf("\nQueue is Empty!!!\n");
else

struct Node *temp = front;

while(temp->next != NULL)

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

temp = temp -> next;

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

}
Output=

You might also like