Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
    #include <iostream> 
    #include <algorithm>
    using namespace std;
    int main ()
    {
    int Array[] = {101, 201, 301, 301, 201, 101, 101, 201};
    int* pbegin = Array;
    int* pend = Array + sizeof(Array) / sizeof(int);
    pend = remove (pbegin, pend, 201);
    for (int* ptr = pbegin; ptr != pend; ++ptr)
    cout << ' ' << *ptr;
    return 0;
    }
    1. 101
    2. 101 301
    3. 101 301 301
    4. 101 301 301 101
    5. 101 301 301 101 101
Correct Option: E

In this program, We are removing all the 201’s and then we are
printing the remaining.



Your comments will be displayed only after manual approval.