Home » C++ Programming » Standard Library » Question
  1. What is the output of this program?
    #include <iostream>
    #include <list>
    #include <string>
    using namespace std ;
    typedef list<string> ListString;
    int main()
    {
    ListString :: iterator k;
    ListString process1;
    process1.insert(process1.end(), "First");
    process1.insert(process1.end(), "Second");
    ListString process2(process1);
    ListString process3(3, "Third");
    ListString process4(++process3.begin(),
    process3.end());
    cout << "Process:";
    for (k = process1.begin(); k != process1.end(); ++k)
    {
    cout << " " << *k << " ";
    }
    cout << "\nProcess:";
    for (k = process2.begin(); k != process2.end(); ++k)
    {
    cout << " " << *k << " ";
    }
    cout << "\nProcess:";
    for (k = process3.begin(); k != process3.end(); ++k)
    {
    cout << " " << *k << " ";
    }
    cout << "\nProcess:";
    for (k = process4.begin(); k != process4.end(); ++k)
    {
    cout << " " << *k << " ";
    }
    }
    1. Process: First Second
      Process: First Second
    2. Process: Third Third Third
      Process: Third Third
      Process: First Second
      Process: First Second
    3. Process: Third Third Third
      Process: Third Third
    4. Process: First Second
      Process: First Second
      Process: Third Third Third
      Process: Third Third
    5. None of these
Correct Option: D

In this program, We used the list to manipulate the given value.



Your comments will be displayed only after manual approval.