Loading...
Searching...
No Matches
Implementation of Linear [Queue using array] (https://www.geeksforgeeks.org/array-implementation-of-queue-simple/). More...
#include <array>
#include <cstdint>
#include <iostream>
Go to the source code of this file.
int main () Main function.Implementation of Linear [Queue using array] (https://www.geeksforgeeks.org/array-implementation-of-queue-simple/).
The Linear Queue is a data structure used for holding a sequence of values, which can be added to the end line (enqueue), removed from head of line (dequeue) and displayed.
AlgorithmValues can be added by increasing the rear variable by 1 (which points to the end of the array), then assigning new value to rear's element of the array.
Values can be removed by increasing the front variable by 1 (which points to the first of the array), so it cannot reached any more.
Definition in file queue_using_array.cpp.
◆ main()Main function.
Allows the user to add and delete values from the queue. Also allows user to display values in the queue.
Definition at line 112 of file queue_using_array.cpp.
112 {
115
116 std::cout << "\n1. enqueue(Insertion) ";
117 std::cout << "\n2. dequeue(Deletion)";
118 std::cout << "\n3. Display";
119 std::cout << "\n4. Exit";
120 while (true) {
121 std::cout << "\nEnter your choice ";
122 std::cin >> op;
123 if (op == 1) {
124 std::cout << "Enter data ";
127 } else if (op == 2) {
129std::cout <<
"\ndequeue element is:\t"<<
data;
130 } else if (op == 3) {
132 } else if (op == 4) {
133 exit(0);
134 } else {
135 std::cout << "\nWrong choice ";
136 }
137 }
138
139 return 0;
140}
Queue_Array class containing the main data and also index of head and tail of the array.
int dequeue()
Delete element from back of the queue.
void enqueue(const int16_t &)
Add element to the first of the queue.
void display() const
Show all saved data.
◆ max_sizeRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4