Answer to Question #295657 in C++ for Sly

Question #295657

Write a c++ program listing courses offered in school


1
Expert's answer
2022-02-09T15:59:20-0500
#include <iostream>
#include <list>
#include <string>
using namespace std;


int main() 
{
	//declaring a list
	list<string> lstr;
	//declaring iterator of the list
	list<string>::iterator l_iter;
	
	//declaring string object
	string str;


	//input courses
	while(true)
	{
		cout<<"Enter your course: (\"EXIT\" to quit): ";
		getline(cin, str);
		if(str=="EXIT")
			break;


		//adding courses to the list 
		lstr.push_back(str);
	}


	//printing list the list of courses
	cout<<"List of Courses Offered in School are"<<endl;
	for (l_iter = lstr.begin(); l_iter != lstr.end(); l_iter++)
		cout<< *l_iter<<endl;

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
New on Blog