Question #59829

Write a program in three parts.
The first part should create a linked list of 26 nodes. The
second part should fill the list with the letters of the
alphabet. The third part should print the contents of the
linked list.

Expert's answer

#include <list>;
using namespace std;
int main()
{
// first part
list <char> alphabet(26);
// second part
char ch = 'a';
for (list <char>::iterator it = alphabet.begin(); it != alphabet.end(); ++it)
*it = ch++;
// third part
for (list <char>::const_iterator it = alphabet.begin(); it != alphabet.end(); ++it)
cout << *it << endl;
return 0;
}
LATEST TUTORIALS
APPROVED BY CLIENTS