From fe9fe5b0a88ea0ab82762a62e0c5d264193375b4 Mon Sep 17 00:00:00 2001 From: Basilmp850 <68513395+Basilmp850@users.noreply.github.com> Date: Sun, 9 Oct 2022 10:46:07 +0530 Subject: [PATCH] Added a cpp program on queue using array and class. --- queueusingarray.cpp | 70 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 queueusingarray.cpp diff --git a/queueusingarray.cpp b/queueusingarray.cpp new file mode 100644 index 0000000..e9f44c9 --- /dev/null +++ b/queueusingarray.cpp @@ -0,0 +1,70 @@ +#include +using namespace std; +#define n 100 + +class Queue{ + + int* arr; + int front; + int back; + +public: + Queue(){ + arr = new int[n]; + front = -1; + back = -1; + } + + void enque(int data){ + if(back == n-1){ + cout<<"Queue Overflow"< back){ + cout<<"No elements in the queue"< back){ + cout<<"No elements in the queue"< back){ + cout<<"No elements in the queue"<