Implementation of queue using linked list.

Added on - 18 Sep 2019

Trusted by +2 million users,
assist thousands of students everyday
Showing pages 1 to 1 of 3 pages
Implementation of queue using linked list#include<stdio.h>#include<conio.h>struct Node{int data;struct Node *next;}*front = NULL,*rear = NULL;void insert(int);void delete();void display();void main(){int choice, value;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 value to be insert: ");scanf("%d", &value);insert(value);break;case 2: delete(); break;case 3: display(); break;case 4: exit(0);default: printf("\nWrong selection!!! Please try again!!!\n");}}}void insert(int value){struct Node *newNode;newNode = (struct Node*)malloc(sizeof(struct Node));newNode->data = value;newNode -> next = NULL;if(front == NULL)front = rear = newNode;else{rear -> next = newNode;rear = newNode;}printf("\nInsertion is Success!!!\n");}void delete(){if(front == NULL)printf("\nQueue is Empty!!!\n");else{struct Node *temp = front;front = front -> next;
desklib-logo
You’re reading a preview
Preview Documents

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Download This Document