deque rend() function in C++ STL
The deque::rend() is an inbuilt function in C++ STL which returns a reverse iterator which points to the position before the beginning of the deque (which is considered its reverse end).
Syntax:
deque_name.rend()
Parameter: This function does not accept any parameters.
Return value: It returns a reverse iterator which points to the position before the beginning of the deque.
Below program illustrates the above function:
Program 1:
// C++ program to illustrate the // deque::rend() function #include <bits/stdc++.h> using namespace std; int main() { deque<int> dq = { 10, 20, 30, 40, 50 }; cout << "The deque in reverse order: "; // prints the elements in reverse order for (auto it = dq.rbegin(); it != dq.rend(); ++it) cout << *it << " "; return 0; } |
The deque in reverse order: 50 40 30 20 10
Program 2:
// C++ program to illustrate the // deque::rend() function #include <bits/stdc++.h> using namespace std; int main() { deque<char> dq = { 'a', 'b', 'c', 'd', 'e' }; cout << "The deque in reverse order: "; // prints the elements in reverse order for (auto it = dq.rbegin(); it != dq.rend(); ++it) cout << *it << " "; return 0; } |
The deque in reverse order: e d c b a
Recommended Posts:
- map rend() function in C++ STL
- list rbegin() and rend() function in C++ STL
- vector rbegin() and rend() function in C++ STL
- multiset rbegin() and rend() function in C++ STL
- deque rbegin() function in C++ STL
- deque insert() function in C++ STL
- deque resize() function in C++ STL
- deque assign() function in C++ STL
- deque max_size() function in C++ STL
- deque::front() and deque::back() in C++ STL
- deque::pop_front() and deque::pop_back() in C++ STL
- deque::empty() and deque::size() in C++ STL
- deque::clear() and deque::erase() in C++ STL
- deque::emplace_front() and deque::emplace_back() in C++ STL
- multimap rend in C++ STL
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



