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 num[] = { 15, 25, 35, 35, 25, 15, 15, 25};
    int* ptrBegin = num;
    int* ptrEnd = num + sizeof(num) / sizeof(int);
    ptrEnd = remove (ptrBegin, ptrEnd, 25);
    for (int* ptr = ptrBegin; ptr != ptrEnd; ++ptr)
    cout << ' ' << *ptr;
    return 0;
    }
    1. 35 35
    2. 15 35
    3. 15 15
    4. 15 35 35 15 15
    5. Compilation Error
Correct Option: D

In this program, We removed the values in the vector by using the remove method.



Your comments will be displayed only after manual approval.