Now I'am using Microsoft Visual Studio to compile this program in C++ but when I compile it I have so many 00000 with no end for this procces..
# include<iostream>
using namespace std;
# define SIZE 5
class queue
{
private:
int a[SIZE];
int front;
int rear;
public:
queue();
~queue();
void insert(int i);
int remove();
int isempty();
int isfull();
int display(int n);
};
queue::queue()
{
front=0;
rear=0;
}
queue::~queue()
{
}
void queue::insert(int i)
{
if(isfull())
{
cout<<"\n******Queue is FULL !!!No insertion allowed further.******";
return;
}
a[rear] = i;
rear++;
}
int queue::remove()
{
if(isempty())
{
cout<<"\n******Queue Empty !!!Value returned will be garbage.******\n";
return (-9999);
}
int i = SIZE ;
while( i--)
{
a[i] = 0;
};
return(a[0]);
}
int queue::isempty()
{
if(front == rear)
return 1;
else
return 0;
}
int queue::isfull()
{
if(rear == SIZE)
return 1;
else
return 0;
}
int queue::display( int n )
{
int i = a[n];
return i;
}
void main()
{
queue q;
int item;
while (!q.isfull())
{
cin>>item;
q.insert(item);
}
while(!q.isempty())
{
int n = SIZE ;
cout << q.display( n) ;
n--;
}
cout<<"\n "<<q.remove();
cout<<"\n"<<q.remove();
}