adplus-dvertising
frame-decoration

Question

What is the output of this program?
    #include <iostream>
    #include <algorithm>
    #include <vector>
    using namespace std;
    bool IsOdd (int i) 
    {
        return (i % 2) == 1; 
    }
    int main () 
    {
        vector<int> myvector;
        for (int i = 1; i < 10; ++i) myvector.push_back(i);
        vector<int> :: iterator bound;
        bound = partition (myvector.begin(), myvector.end(), IsOdd);
        for (vector<int> :: iterator it = myvector.begin(); it != bound; ++it)
            cout << ' ' << *it;
        return 0;
    }

a.

1 3 5

b.

1 3 9

c.

1 9 3 7

d.

1 9 3 7 5

Answer: (d).1 9 3 7 5

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?