#include<iostream>
using namespace std;
const int size =5;
class queue
{
private:
int front,rear,n;
int q[size];
public:
queue()
{
front=0;
rear=0;
}
void insert()
{
if(rear==size)
{
cout<<"queue is full."<<endl;
}
else
{
cout<<"enter the data in queue:";
cin>>n;
q[rear]=n;
rear++;
insert();
}
}
void rem()
{
if(rear==front)
{
cout<<"queue is empty."<<endl;
}
else
{
cout<<"the deleted data is:"<<q[front]<<endl;
q[front]==NULL
front++;
rem();
}
}
};
int main()
{
queue q1;
q1.insert();
q1.rem();
return 0;
}
0 comments:
Post a Comment