Questions and Answers
- What is the output of this program?
#include <iostream>
#include <deque>
using namespace std;
int main ()
{
unsigned int k;
deque<int> DequeData;
DequeData.push_back (50);
DequeData.push_back (75);
DequeData.push_back (90);
for(deque<int> :: iterator iter = DequeData.begin(); iter != DequeData.end(); ++iter)
{
}
DequeData.clear();
DequeData.push_back (150);
DequeData.push_back (175);
for(deque<int> :: iterator iter = DequeData.begin(); iter != DequeData.end(); ++iter)
cout << ' ' << *iter;
cout << '\n';
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
In this program, We cleared the old values presented in the dequeue with the new values.
- What is the output of this program?
#include <iostream>
#include <deque>
using namespace std;
int main ()
{
unsigned int k;
deque<int> FirstDeque (4,125);
deque<int> SecondDeque (5,150);
FirstDeque.swap(SecondDeque);
cout << "First Data contains:";
for (deque<int>::iterator iter = FirstDeque.begin(); iter != FirstDeque.end(); ++iter)
cout << ' ' << *iter;
cout << "\nSecond Data contains:";
for (deque<int>::iterator iter = SecondDeque.begin(); iter != SecondDeque.end(); ++iter)
cout << ' ' << *iter;
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
In this program, We swapped the values of both dequeues and printing the dequeues.
- What is the output of this program?
#include <iostream>
#include <deque>
using namespace std;
int main ()
{
deque<int> DequeData (6);
deque<int>::reverse_iterator RevIter = DequeData.rbegin();
int k = 0;
for (RevIter = DequeData.rbegin(); RevIter != DequeData.rend(); ++RevIter)
*RevIter = ++k;
for (deque<int> :: iterator iter = DequeData.begin();
iter != DequeData.end(); ++iter)
cout << ' ' << *iter;
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
In this program, We used the operation of rbegin and rend on dequeue and produced the result.
- Which of the following will return the new element at the end of container?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
back
- Which of the following class template are based on arrays?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Class template vector and class template dequeue both are based on arrays.