Not a member of GistPad yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define SIZE 5
- int queue_arr[SIZE];
- int front = -1;
- int rear = -1;
- void insert_element(int value)
- {
- if (rear == SIZE - 1)
- {
- cout << "Queue Overflow" << endl;
- }
- else
- {
- if (front == -1)
- {
- front = 0;
- }
- rear = rear + 1;
- queue_arr[rear] = value;
- cout << "Element Inserted Successfully" << endl;
- }
- }
- int main()
- {
- int num;
- cout << "Enter element to insert: ";
- cin >> num;
- insert_element(num);
- return 0;
- }
RAW Paste Data
Copied
