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);
cout << (p1 == p2) << \" \";
cout << (p1 != p2) << endl;
cout << (p1 <= p2) << \" \";
cout << (p1 >= p2) << endl;
return 0;
}
Output of the above program
(A) 0 1
1 0
(B) 0 0
1 1
(C) 0 1
0 1
(D) 1 1
1 1
Answer: (A)
Explanation:
comparison(==) operator: compares two pairs its first and second value and returns 1 if true else 0.
Not equal (!=) operator: compares two operator, the first value and then second value and return 1 if not equal else 0.
logical operator(<=, >=): it returns 0 or 1 on comparing only first value of pair.
Share your thoughts in the comments
Please Login to comment...