Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
#include
3.
using namespace std;
4.
int main ()
5.
{
6.
deque mydeque (5);
7.
deque::reverse_iterator rit = mydeque.rbegin();
8.
int i = 0;
9.
for (rit = mydeque.rbegin(); rit!= mydeque.rend(); ++rit)
10.
*rit = ++i;
11.
for (deque :: iterator it = mydeque.begin();
12.
it != mydeque.end(); ++it)
13.
cout
Options:
A .  12345
B .  1234
C .  54321
D .  43210
Answer: Option C

In this program, We used the operation of rbegin and rend on dequeue and produced the result.
Output:
$ g++ seq.cpp
$ a.out
5 4 3 2 1



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers