Home » C++ Programming » Questions and Answers » Question
  1. What is the output of this program?
    #include <iostream>
    #include <algorithm>
    #include <vector>
    using namespace std;
    bool IsOdd (int k)
    {
    return (k % 3) == 1;
    }
    int main ()
    {
    vector<int> num;
    for (int k = 1; k < 15; ++k) num.push_back(k);
    vector<int> :: iterator bound;
    bound = partition (num.begin(), num.end(), IsOdd);
    for (vector<int> :: iterator Iter = num.begin(); Iter != bound; ++Iter)
    cout << ' ' << *Iter;
    return 0;
    }
    1. 1
    2. 1 13
    3. 1 13 10
    4. 1 13 10 4
    5. 1 13 10 4 7
Correct Option: E

In this program, We are finding the odd values in the sequence.



Your comments will be displayed only after manual approval.