What will be the output of the following C++ code?
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
bool mypredicate (int i, int j)
{
return (i == j);
}
int main ()
{
vector<int> myvector;
for (int i = 1; i < 6; i++) myvector.push_back (i * 10);
int myints[] = {10, 20, 30, 40, 1024};
pair<vector<int> :: iterator, int*> mypair;
mypair = mismatch (myvector.begin(), myvector.end(), myints);
cout << *mypair.first<<'\n';
cout << *mypair.second << '\n';
++mypair.first; ++mypair.second;
return 0;
}
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
bool mypredicate (int i, int j)
{
return (i == j);
}
int main ()
{
vector<int> myvector;
for (int i = 1; i < 6; i++) myvector.push_back (i * 10);
int myints[] = {10, 20, 30, 40, 1024};
pair<vector<int> :: iterator, int*> mypair;
mypair = mismatch (myvector.begin(), myvector.end(), myints);
cout << *mypair.first<<'\n';
cout << *mypair.second << '\n';
++mypair.first; ++mypair.second;
return 0;
}A. 40
1024
B. 50
1024
C. 20
1024
D. 1024
Answer: Option B

Join The Discussion