CIRCQUE - } printf("Data:\n");

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 ROLL NO 02 SE CMPN A */ struct cqueue { int arr[max]; int front; int rear; }; } void insert(struct cqueue *s,int v) { { 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;} printf("Inserted : %d at %d \n",s->arr[s->rear],s->rear); } 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; } else { if(s->front==max-1) s->front=0; else (s->front)++; } return d; } void display(struct cqueue *s)
Background image of page 1

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

View Full DocumentRight Arrow Icon
{ int z=s->front; if((s->front==-1)) { printf("Array is empty\n"); return;
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } printf(&quot;Data:\n&quot;); while(z&lt;=s-&gt;rear) { printf(&quot;%d) %d\n&quot;,z,s-&gt;arr[z]); z++; } if(s-&gt;rear&lt;s-&gt;front) { while(z&lt;max) { printf(&quot;%d) %d\n&quot;,z,s-&gt;arr[z]); z++; } z=0; while(z&lt;=s-&gt;rear) { printf(&quot;%d) %d\n&quot;,z,s-&gt;arr[z]); z++; } } } void main() { struct cqueue p; int x,d,a; p.front=-1; p.rear=-1; clrscr(); do { printf(&quot;Enter 1-insert 2-delete 3-display 0-exit : &quot;); scanf(&quot;%d&quot;,&amp;a); switch(a) { case 0:{break;} case 1:{printf(&quot;Enter the Element to be inserted : &quot;); scanf(&quot;%d&quot;,&amp;x); insert(&amp;p,x); break; } case 2:{d=del(&amp;p); printf(&quot;The elment deleted is %d\n&quot;,d); break; } case 3:{ display(&amp;p); break; } default:{printf(&quot;Invalid Choice\n&quot;);} } }while(a!=0); getch(); }...
View Full Document

Page1 / 3

CIRCQUE - } printf(&amp;amp;quot;Data:\n&amp;amp;quot;);

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