This document defines a circular queue data structure and provides functions to perform basic queue operations. A circular queue is implemented using a fixed-size array with front and rear pointers. Functions are provided to enqueue an element, dequeue an element, check if the queue is empty or full, and perform sample operations on the queue. The main function allows the user to choose between integer, character, or float queues and calls the operations function to demonstrate usage.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
96 views
Circular Queue
This document defines a circular queue data structure and provides functions to perform basic queue operations. A circular queue is implemented using a fixed-size array with front and rear pointers. Functions are provided to enqueue an element, dequeue an element, check if the queue is empty or full, and perform sample operations on the queue. The main function allows the user to choose between integer, character, or float queues and calls the operations function to demonstrate usage.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3
Circular Queue
/* Program to perform basic operations on Circular Queues */
/* if Queue is EMPTY then empty=1, otherwise empty=0 */ /* if Queue is FULL then empty=0 and ((rear+1)mod n ) = front */ /* initially rear=n-1 and front =0 */
#include<iostream.h> #include<stdlib.h>
template<class T> class CQueue { int front, rear; int n,empty; T *Q; public: CQueue(); void enQueue(T); T deQueue(); void operations(); int isEmpty(); int isFull(); };
template<class T> CQueue <T>::CQueue() { cout<<"\n enter Size of the Queue:"; cin>>n;