/*PROGRAM TO INSERT ELEMENTS IN CIRCULAR QUEUE*/
#include<conio.h>
#include<iostream.h>
#include<stdlib.h>
#define MAX 5
void main()
{
int front=-1,rear=-1,i,a[MAX],item;
char ch;
clrscr();
do
{
if((front==0 && rear==MAX-1)||(front==rear+1))
{
cout<<“Queue is full”<<endl;
break;
}
else if(front==-1 && rear==-1)
{
rear=0;
front=0;
cout<<“Enter the element you want to insert: “;
cin>>item;
a[rear]=item;
}
else if(rear==MAX-1 && front!=0)
{
rear=0;
cout<<“Enter the element you want to insert: “;
cin>>item;
a[rear]=item;
}
else
{
rear++;
cout<<“Enter the element you want to insert: “;
cin>>item;
a[rear]=item;
}
cout<<“Do you want to insert more elements: “;
cin>>ch;
}while(ch==’y’);
cout<<“Elements in the queue are: “<<endl;
for(i=front;i<=rear;i++)
{
cout<<a[i]<<“\t”;
}
getch();
}