Examveda

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;
}

A. 40
1024

B. 50
1024

C. 20
1024

D. 1024

Answer: Option B


Join The Discussion

Related Questions on C plus plus miscellaneous

What is the difference between '++i' and 'i++' in C++?

A. None of the above

B. They both have the same effect

C. '++i' increments the value of 'i' before returning it, while 'i++' increments the value of 'i' after returning it

D. '++i' increments the value of 'i' after returning it, while 'i++' increments the value of 'i' before returning it