// Dickens Fenelon
// Data
Structures
//
"Circular Queue"
#include<iostream.h>
#include<stdlib.h>
void enqueue (int[], int&, int);//Function
Prototypes
int dequeue (int[],
int&); //Function
Prototypes
int isempty (); //Fucntion Prototyepes
int isfull (const int); //Function
Prototypes
int counter = 0;//Initializing counter to
0
void enqueue(int myqueue[],
int &rear, int x)
{
myqueue[rear] = x;
rear = rear + 1;
counter = counter +
1;
}//Enqueue Function
int dequeue(int myqueue[], int &front)
{
int x = myqueue[front];
front = front + 1;
counter = counter -
1;
return
x;
}//Dequeue Function
int isempty()
{
if(counter
== 0)
return 1;
else
return 0;
}//Isempty Function
int isfull(const
int maxQ)
{
if(counter
== maxQ)
return 1;
else
return 0;
}//Isfull Function
void main()
{
const
int maxQ = 5;
int myqueue[maxQ];
int front = 0;
int rear = 0;
int x;
char
choice;
do{
cout << "Select One Of The Following
Options:" << endl;
cout
<< "1-Enqueue 2-Dequeue 3-Isempty 4-Isfull 5-Quit: ";
cin
>> choice;
switch(choice){
case '1':
cout << "Enter The
Number That Will Be Queued: " << endl;
cin >> x;
if(!isfull(maxQ))
enqueue(myqueue, rear, x);
else
cout
<< "You Can't Enqueue " << endl;
break;
case
'2':
if(!isempty())
cout<<"The
Number Dequeued Is:" <<dequeue(myqueue, front)<< endl;
else
cout<<"Sorry
You Can't Dequeue" <<endl;
break;
case
'3':
if(isempty())
cout<<"Queue
Is Empty."<<endl;
else
cout<<"Queue
Is Not Empty."<<endl;
break;
case
'4':
if(isfull(maxQ) == 1)
cout<<"Queue
Is Full."<<endl;
else
cout<<"Queue
Is Not Full. "<<endl;
break;
case
'5':
system("cls");
cout<<"Thank
You For Using Dicken's Menu!!!!!"<<endl;
break;
default:
cout<<"Please
Enter The Correct Options."<<endl;
}//End Swicth
} while(choice
!='5');//End Do/while
}//End