CIRCULAR QUEUE PRINTOUT

CIRCULAR QUEUE - #include#include#definemax10*RISHIAGARWAL ROLLNO02 SECMPNA CIRCULARQUEUE structcqueue cfw intarr[max intfront

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 DocumentRight 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.

This note was uploaded on 10/25/2010 for the course CMPN SEM3 taught by Professor Thakur during the Fall '07 term at University of Mumbai.

Page1 / 4

CIRCULAR QUEUE - #include#include#definemax10*RISHIAGARWAL ROLLNO02 SECMPNA CIRCULARQUEUE structcqueue cfw intarr[max intfront

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