C Program to implement QUEUE operations using Linked Lists

Data structures using C,
C Program to implement QUEUE operations using Linked list. Queue is a abstract data type, In which entities are inserted into the rear end and deleted from the front end. Here to implement queue we used the Linked lists!. Read more about C Programming Language .

* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
* Happy Coding

#include <stdlib.h>
typedef struct node {
int data;
struct node *link;

void Insert(int);
int Delete();
void Display();
NODE *front, *rear; /* Global Declarations */

main() {
/* Main Program */
int opn, elem;
front = rear = NULL;
do {
printf("n ### Linked List Implementation of QUEUE Operations ### nn");
printf("n Press 1-Insert, 2-Delete, 3-Display,4-Exitn");
printf("n Your option ? ");
scanf("%d", &opn);
switch (opn) {
case 1:
printf("nnRead the Element to be Inserted ?");
scanf("%d", &elem);
case 2:
elem = Delete();
if (elem != -1)
printf(" Deleted Node(From Front)with the Data: %dn", elem);
case 3:
printf("Linked List Implementation of Queue: Status:n");
case 4:
printf("nn Terminating nn");
printf("nnInvalid Option !!! Try Again !! nn");
printf("nnnn Press a Key to Continue . . . ");
} while (opn != 4);

void Insert(int info) {
NODE *temp;
temp = (NODE *) malloc(sizeof(NODE));
if (temp == NULL)
printf(" Out of Memory !! Overflow !!!");
else {
temp->data = info;
temp->link = NULL;
if (front == NULL) {
front = rear = temp;
} /* First Node? */
else {
rear->link = temp;
rear = temp;
} /* Insert End */
printf(" Node has been inserted at End Successfully !!");

int Delete() {
int info;
NODE *t;
if (front == NULL) {
printf(" Underflow!!!");
return -1;
} else {
t = front;
info = front->data;
if (front == rear)
rear = NULL;
front = front->link;
t->link = NULL;
return (info);

void Display() {
NODE *t;
if (front == NULL)
printf("Empty Queuen");
else {
t = front;
while (t) {
printf("[%d]->", t->data);
t = t->link;
Read more Similar C Programs
Data Structures

Learn C Programming

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

Leave a Reply