#include<iostream>
using namespace std;
const int s = 5;
int q[s], r = 0, f = 0;
void enque(int v)
{
if(r == s)
{
cout << "Queue is Full.." << endl;
}
else
{
q[r] = v;
r++;
}
}
void dque()
{
if(f == r)
{
cout << "Queue is Empty.." << endl;
}
else
{
f++;
}
}
void display()
{
int i;
if(f == r)
{
cout << "Queue is Empty.." << endl;
}
else
{
cout << "Current Queue :: ";
for(i=f;i<r;i++)
{
cout << q[i] << " ";
}
cout << endl;
}
}
int main()
{
enque(1);
enque(2);
enque(3);
enque(4);
enque(5);
display();
dque();
dque();
dque();
display();
dque();
dque();
display();
return 0;
}
using namespace std;
const int s = 5;
int q[s], r = 0, f = 0;
void enque(int v)
{
if(r == s)
{
cout << "Queue is Full.." << endl;
}
else
{
q[r] = v;
r++;
}
}
void dque()
{
if(f == r)
{
cout << "Queue is Empty.." << endl;
}
else
{
f++;
}
}
void display()
{
int i;
if(f == r)
{
cout << "Queue is Empty.." << endl;
}
else
{
cout << "Current Queue :: ";
for(i=f;i<r;i++)
{
cout << q[i] << " ";
}
cout << endl;
}
}
int main()
{
enque(1);
enque(2);
enque(3);
enque(4);
enque(5);
display();
dque();
dque();
dque();
display();
dque();
dque();
display();
return 0;
}
Comments
Post a Comment