Questions and Answers
- 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;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
In this program, We used priority_queue and with that we are pushing and popping out the elements.
- What is the output of this program?
#include <iostream>
#include <queue>
using namespace std;
int main ()
{
queue<int> QueueData;
int add (0);
for (int k = 1; k <= 50; k++)
QueueData.push(k);
while (!QueueData.empty())
{
add += QueueData.front();
QueueData.pop();
}
cout << add << endl;
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
In this program, We used the push and pop operation of quueue to find out the total of all the number from 1 to 50.
- What is the output of this program?
#include <iostream>
#include <queue>
using namespace std;
int main ()
{
queue<int> QueueData;
QueueData.push(15);
QueueData.push(45);
QueueData.back() -= QueueData.front();
cout << QueueData.back() << endl;
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
In this program, We used the queue operation and performed the back operation. Because of that operation, We got the output as 30.
- Which are presented in the container adaptors?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
These mentioned things are presented in container adapters.
- What does the sequence adaptor provide?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Interface to sequence container