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

Implementation of Linear Queue Using Linked List

The document provides a C implementation of a linear queue using a linked list. It includes functions for inserting, deleting, and displaying elements in the queue, along with a main function that handles user choices for these operations. The code also manages memory allocation and checks for overflow and underflow conditions.
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)
2 views

Implementation of Linear Queue Using Linked List

The document provides a C implementation of a linear queue using a linked list. It includes functions for inserting, deleting, and displaying elements in the queue, along with a main function that handles user choices for these operations. The code also manages memory allocation and checks for overflow and underflow conditions.
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

Implementation of Linear Queue using Linked List

#include<stdio.h>

#include<stdlib.h>

struct node

int data;

struct node *next;

};

struct node *front;

struct node *rear;

void insert();

void delete();

void display();

void main ()

int choice;

while(choice != 4)

printf("\nEnter your choice ?");

scanf("%d",& choice);

switch(choice)

case 1:

insert();

break;

case 2:

delete();

break;

case 3:

display();

break;

case 4:
Implementation of Linear Queue using Linked List

exit(0);

break;

default:

printf("\nEnter valid choice??\n");

void insert()

struct node *ptr;

int item;

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

if(ptr == NULL)

printf("\nOVERFLOW\n");

return;

else

printf("\nEnter value?\n");

scanf("%d",&item);

ptr -> data = item;

if(front == NULL)

front = ptr;

rear = ptr;

front -> next = NULL;

rear -> next = NULL;

else
Implementation of Linear Queue using Linked List

rear -> next = ptr;

rear = ptr;

rear->next = NULL;

void delete ()

struct node *ptr;

if(front == NULL)

printf("\nUNDERFLOW\n");

return;

else

ptr = front;

front = front -> next;

free(ptr);

void display()

struct node *ptr;

ptr = front;

if(front == NULL)

printf("\nEmpty queue\n");

else
Implementation of Linear Queue using Linked List

{ printf("\nprinting values\n");

while(ptr != NULL)

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

ptr = ptr -> next;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy