#include <iostream>
#include <list>
#include <string>
usingnamespace std;
void print_list(list<string> somelist);
int main()
{
list <string> grocery;
list <string>::iterator it;
grocery.empty()'
{if(grocery.empty())
cout<<"List is empty."<<endl;
else
cout<<"List is not empty."<<endl;
}//checking if list is empty or not
cout<<endl;
//adding items
grocery.push_back("Milk");
grocery.push_back("Eggs");
grocery.push_back("Butter");
grocery.push_back("Apple");
grocery.push_back("Bread");
grocery.push_back("Chicken");
print_list(grocery);//print out of elements
cout<<endl;
list<string>::size_type i;
i=grocery.size();
cout<<"The size of the grocery list is: "<<i<<endl<<endl;; //displays size of list
grocery.remove("Apple");
print_list(grocery);
cout<<endl;
list<string>::size_type j;
j=grocery.size();
cout<<"The size of the Grocery list is: "<<j<<endl<<endl; //displays size of list
grocery.insert(4,"Banana") ;
print_list(grocery); //replacing banana instead of Apple
cout<<endl;
cout<<"The fifth element is: "<<grocery[5]<<endl;
return 0;
}
void print_list(list<string> somelist)
{
list<string>::iterator itt;
for (itt=somelist.begin(); itt!=somelist.end(); ++itt)
cout<<""<< *itt<<endl;
cout<<endl;
}