-
What is the output of this program?
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
vector<int> firstRow (4, 15);
vector<int> secondRow (4, 26);
vector<int>::iterator iter;
swap_ranges(firstRow.begin() + 1, firstRow.end() - 1, secondRow.begin());
cout << "First Row contains:";
for (iter = firstRow.begin(); iter != firstRow.end(); ++iter)
cout << " " << *it;
cout << "\nSecond Row contains:";
for (it = secondRow.begin(); it != secondRow.end(); ++it)
cout << " " << *it;
return 0;
}
-
- Second Row contains: 15 15 26 26
First Row contains: 15 26 26 15 - First Row contains: 15 26 26 15
- First Row contains: 15 26 26 15
Second Row contains: 15 15 26 26 - Second Row contains: 15 15 26 26
- None of these
- Second Row contains: 15 15 26 26
Correct Option: C
In this program, We swapped the values according to their position.