
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

#include<conio.h> #include<iostream.h> int rear=-1,front=-1,queue[10],max=10; void main (void) { int choice,i=0,input; clrscr(); cout<<"Enter your choice\n\t\tTo enter press: 1\n\t\tTo exit press:2\n"; cin>>input; while (input==1) { cout<<"Enter the number of pages\n"; cin>>choice; if(front==-1||rear==-1) { front=0; rear=0; queue[rear]=choice; } if(rear>(max-1)) { cout<<"The queue is full\n"; } else { rear=0; while (choice>queue[rear]) { rear++; for(int j=max;j>rear;j--) { queue[j]=queue[j-1]; } } queue[rear]=choice; } cout<<"The Queue is:\n"; for(int k=0;k<=10;k++) { cout<<queue[k]<<" "; } cout<<"\nEnter Choice\n"; cin>>input; } getch(); }