0% found this document useful (0 votes)
4 views3 pages

DSC Exp 10

Uploaded by

ayushoffical14
Copyright
© © All Rights Reserved
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% found this document useful (0 votes)
4 views3 pages

DSC Exp 10

Uploaded by

ayushoffical14
Copyright
© © All Rights Reserved
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

EXPERIMENT-10

WAP to Implement QUEUE using arrays that per- forms following operations a) INSERT b)
DELETE c) DISPLAY

#include <iostream>

#include <queue>

using namespace std;

int main() {

queue<int> q;

int choice, value;

while (true) {

cout << "\nMenu:\n";

cout << "1. INSERT (Enqueue)\n";

cout << "2. DELETE (Dequeue)\n";

cout << "3. DISPLAY Queue\n";

cout << "4. Exit\n";

cout << "Enter your choice: ";

cin >> choice;

switch (choice) {

case 1:

cout << "Enter the value to insert: ";

cin >> value;

q.push(value);

cout << "Inserted " << value << " into the queue.\n";

break;

case 2:
if (!q.empty()) {

cout << "Deleted value: " << q.front() << endl;

q.pop();

} else {

cout << "The queue is empty.\n";

break;

case 3:

if (!q.empty()) {

cout << "Queue elements:\n";

queue<int> temp = q;

while (!temp.empty()) {

cout << temp.front() << " ";

temp.pop();

cout << endl;

} else {

cout << "The queue is empty.\n";

break;

case 4:

cout << "Exiting the program.\n";

return 0;

default:

cout << "Invalid choice! Please try again.\n";

return 0;

You might also like