Answer to Question #59829 in C++ for adrain

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.
1
Expert's answer
2016-05-11T08:48:02-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS