Last Updated : 10 Apr, 2024
#include <iostream>
#include <utility>
using namespace std;

int main() 
{
    pair <int, int> p1;
    p1.first = 1;
    p1.second = 20;
    
    pair <int, int> p2;
    p2 = make_pair(2, 30);  // line 1
    cout << p1.first << \" \" << p2.second;
    
    return 0;
} 

Output of the above program
(A) 1 30
(B) 20 30
(C) 2 30
(D) error in line 1


Answer: (A)

Explanation:
make_pair(value1, value2) is a template function allows to create pairs.


Share your thoughts in the comments