Vidyalelo
C++ Programming · Q603

C++ miscellaneous

Programming · C++ Programming · question 603

Q603

What will be the output of the following C++ code? #include #include #include using namespace std; int main () pair p1(1,2); pair p2(3,4); cout<<"Pair(first,second) = ("<<p1.first<<","<<p1.second<<") "; p1.swap(p2); cout<<"Pair(first,second) = ("<<p1.first<<","<<p1.second<<") "; return 0;

A.
Pair(first,second) = (1,2)
Pair(first,second) = (3,4)
Answer
B.
Pair(first,second) = (3,4)
Pair(first,second) = (1,2)
C.
Pair(first,second) = (1,2)
Pair(first,second) = (1,2)
D.
Pair(first,second) = (3,4)
Pair(first,second) = (3,4)

Answer: Option A

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board