Last Updated :
10 Apr, 2024
Predict the output for the below program
#include <iostream>
#include <utility>
using namespace std;
int main()
{
pair <int, int> pr1;
pr1.first = 1;
pr1.second = 20;
pair <int, int> pr2;
pr2.first = 2;
pr2.second = 30;
pr1.first = pr2.first++ + ++pr1.first;
pr2.second = pr2.second++ - --pr2.second;
cout << pr1.first <<\" \" << pr2.second;
return 0;
}
(A) 3 1
(B) 4 0
(C) 4 1
(D) None of the mentioned
Answer: (B)
Explanation:
Two pairs pr1 and pr2 with their respective first and second values initialized. Their values are updated using arithmetic operators.
Share your thoughts in the comments
Please Login to comment...