Question #220486

Generate the driver file (main.cpp) where you perform the following tasks. Note that you cannot make any change to

the header file or the source file.

Operation to Be Tested and Description of Action Input Values Expected Output

Create a list of integers Print length of the list


Expert's answer

#include <iostream>
#include <list>

int main()
{
  std::list<int> lst;
  
  int input;
  while (std::cin >> input) {
    lst.push_back(input);
  }

  std::cout << "Length of the list:" << lst.size() << std::endl;  

  return 0;
}
LATEST TUTORIALS
APPROVED BY CLIENTS