This quiz tests your knowledge of C++ Deque container and its associated operations. It contains 10 MCQs.
Question 1
What will be the output of the following C++ program?
#include <iostream> #include <queue> using namespace std; int main() { queue<int> myqueue; myqueue.push(80); myqueue.push(70); myqueue.push(60); myqueue.push(50); if (myqueue.front() > myqueue.back()) { cout << myqueue.front() - myqueue.back(); } else if (myqueue.front() < myqueue.back()) { cout << myqueue.back() - myqueue.front(); } else cout << "0"; }
50
70
30
130
Question 2
What will be the output of the following C++ code?
#include <iostream> #include <queue> using namespace std; int main() { queue<int> myqueue; myqueue.push(30); myqueue.push(40); myqueue.push(10); myqueue.push(50); cout << myqueue.back(); return 0; }
30
40
10
50
Question 3
Which of the following statements about the queue container is false?
It is a first-in, first-out (FIFO) data structure.
It has a front and a back, but no random access to elements.
It has a fixed size.
It is implemented as a dynamic array.
Question 4
Which of the following is not a valid way to initialize a queue in C++?
queue<int> q;
queue<int> q(5);
queue<int> q({1, 2, 3});
queue<int> q(q2);
Question 5
Which of the following is not a member function of the queue STL in C++?
empty()
size()
get()
push()
Question 6
What is the main property of a queue?
LIFO (last in, first out)
FIFO (first in, first out)
Both a and b
None of the above
Question 7
Which of the following is not a member function of the queue STL in C++?
pop()
push()
front()
insert()
Question 8
Can the queue STL in C++ be used to store elements of different data types?
Yes
No
Question 9
What is the complexity of the size() member function of the queue STL in C++?
O(1)
O(n)
O(log n)
O(n log n)
Question 10
Can the queue STL in C++ be used to store elements of a user-defined data type?
Yes
No
There are 10 questions to complete.