Posts

Showing posts with the label queue

IMPLEMENTATION OF QUEUE BY LINKEDLIST : C PROGRAM

Image
  Hey there ,welcome to yocoding. Here is the code for queue by linked list in C programming language. Program code : #include<stdio.h> #include <stdlib.h> struct node {     int data;     struct node *next; }; struct node *rear=NULL,*front=NULL; void enque(int d) {     struct node *p;     p=(struct node *)malloc(sizeof(struct node));     p->data=d;     if(front==NULL)     {         p->next=NULL;         front=p;         rear=p;         return;     }     rear->next=p;     p->next=NULL;     rear=p;     return; } void deque() {     struct node *temp;     if(front==NULL)         printf("queue is empty.\n");     else if(front==rear){         printf("deleted element %d.\n",front->data);   ...

IMPLEMENTATION OF QUEUE BY ARRAY : C PROGRAM

Image
  Here is the C program for implementation of queue using array.  Queue is a data structure.  program code : #include<stdio.h> #include<stdlib.h> int que[6],f=-1;r=-1; void enque(int d) {     if(f==5)     {         printf("queue is full,enque not possible.\n");         return;     }     if(f==-1)     {         f=r=0;         que[r]=d;     }     else{         r++;         que[r]=d;     } } void deque() {     if(f==-1){         printf("list is empty,deletion not possible\n");         return;     }     if(f==r){         printf("deleted element is %d\n",que[r]);         f=r=-1;     }     else{         printf("deleted ele...