Examveda

What will be the output of the following C++ code?
#include <iostream>
#include <queue>
using namespace std;
int main ()
{
    priority_queue<int> mypq;
    mypq.push(30);
    mypq.push(100);
    mypq.push(25);
    mypq.push(40);
    while (!mypq.empty())
    {
        cout << " " << mypq.top();
        mypq.pop();
    }
    cout << endl;
    return 0;
}

A. 100 40 30 25

B. 100 40 30

C. 100 40

D. 100 30 25

Answer: Option A


Join The Discussion

Related Questions on C plus plus miscellaneous

What is the difference between '++i' and 'i++' in C++?

A. None of the above

B. They both have the same effect

C. '++i' increments the value of 'i' before returning it, while 'i++' increments the value of 'i' after returning it

D. '++i' increments the value of 'i' after returning it, while 'i++' increments the value of 'i' before returning it