// CPP program to illustrate the
// list::reverse() function
#include <bits/stdc++.h>
using namespace std;
int main()
{
// Creating a list
list<int> demoList;
// Adding elements to the list
demoList.push_back(10);
demoList.push_back(20);
demoList.push_back(30);
demoList.push_back(40);
// Initial list:
cout << "Initial List: ";
for (auto itr = demoList.begin(); itr != demoList.end(); itr++)
cout << *itr << " ";
// reversing the list
demoList.reverse();
// List after reversing the order of elements
cout << "\n\nList after reversing: ";
for (auto itr = demoList.begin(); itr != demoList.end(); itr++)
cout << *itr << " ";
return 0;
}