CIRCULAR QUEUE PRINTOUT

CIRCULAR QUEUE PRINTOUT -...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<stdio.h> #include<conio.h> #define max 10 /*RISHI AGARWAL CIRCULAR QUEUE   ROLL NO 02   SE CMPN A */ struct cqueue {  int arr[max];  int front;  int rear; }; void insert(struct cqueue *s,int v) {  if(((s->rear==max-1)&&(s->front==0))||(s->front==s- >rear+1))  {   printf("Array is full\n");   return;  }  if(s->rear==max-1)   s->rear=-1;  (s->rear)++;  s->arr[s->rear]=v;  if(s->front==-1)  {s->front=0;} } int del(struct cqueue *s) {  int d;  if((s->front==-1))  {   printf("Array is empty\n");   return NULL;  }  d=s->arr[s->front];  if(s->front==s->rear)  {   s->front=-1;   s->rear=-1;}
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
 {   if(s->front==max-1)   s->front=0;   else   (s->front)++;  }  return d;} void display(struct cqueue *s) {  int z=s->front;   if((s->front==-1))  {   printf("Array is empty\n");   return;  }  printf("Data:\n");   while(z<=s->rear)   {    printf("%d) %d\n",z,s->arr[z]);    z++;   }
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 4

CIRCULAR QUEUE PRINTOUT -...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online