Making a program that capture a name and place of last in an array of string which must be kept on a rolling cycle and capturing the above so that the new is the last and the first to be removed or taken out of the arrangement.
#include <iostream>
#include <string>
#include <queue>
usingnamespace std;
int main()
{
string name;
queue<string> name_q;
// Get the name(s) from the user.
cout << "Enter name(s). Enter an empty line to finish.\n";
while(getline(cin, name) && !name.empty())
name_q.push (name);
// Print the name(s) in the queue.
cout << "There are " << name_q.size() << " elements in the queue. They are: \n" ;
while (!name_q.empty())
{
cout << name_q.front() << "\n";
name_q.pop();
}
cout << '\n';
return 0;
}