Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
    #include <iostream>
    #include <queue>
    using namespace std;
    int main ()
    {
    priority_queue<int> QueueData;
    QueueData.push(25);
    QueueData.push(75);
    QueueData.push(45);
    QueueData.push(55);
    while (!QueueData.empty())
    {
    cout << " " << QueueData.top();
    QueueData.pop();
    }
    cout << endl;
    return 0;
    }
    1. 75 65 55 45 25
    2. 75 65 55 45
    3. 75 65 55
    4. 75 65
    5. 75
Correct Option: A

In this program, We used priority_queue and with that we are pushing and popping out the elements.



Your comments will be displayed only after manual approval.