You are on page 1of 5

UNIVERSITY OF GUJRAT

Name : Zeeshan Mazhar

Roll No : 21014198-139

Department : Software Engineering

Section : C -21

Submitted To : Mr.Wasif Ali

Assignment : 01

Course Name : Data Structure and Algorithms

Data : 10-Feb-2023
#include<iostream>

using namespace std;

class CQueue

int CQ[5],front,rear,n,counter;

public:

CQueue()

front=-1;

rear=-1;

n=5;

counter=0;

void Insertion(int data)

if(counter==n)

cout<<"Circular Quene is full."<<endl;

else

rear=(rear+1)%n;

CQ[rear]=data;

if(front==-1)

{
front=0;

counter++;

void Deletion()

if(counter==0)

cout<<"Circular Quene is empty."<<endl;

else if(front==rear)

rear=-1;

front=-1;

else

front=(front+1)%n;

counter--;

void Show()

for(int i=0;i<=counter-1;i++)
{

cout<<CQ[(front+i)%n]<<" ";

cout<<endl;

};

int main()

CQueue W;

W.Insertion(10);

cout<<"Queue after first insertion\t";

W.Show();

W.Insertion(20);

cout<<"Queue after Second Insertion\t";

W.Show();

W.Deletion();

cout<<"Queue after Deletion\t";

W.Show();

W.Insertion(30);

cout<<"Queue after last Insertion\t";

W.Show();

return 0;

You might also like