Last Updated : 10 Apr, 2024
vector <int> v = {2, 4, 1, 3, 4, 6, 7, 8};
    for(auto itr = v.rbegin(); itr != v.rend(); itr++)
       cout << *itr << \" \";

Output of the above program
(A) 2 4 1 3 4 6 7 8
(B) 1 2 3 4 4 6 7 8
(C) 8 7 6 4 3 1 4 2
(D) None of the mentioned


Answer: (C)

Explanation:
rbegin(): It returns a reverse iterator pointing to the last element in the container.
rend(): It returns a reverse iterator pointing to the theoretical element right before the first element in the container.


Share your thoughts in the comments