C++20 sections · 1024 units
Open in Course

Quiz: Swap Implementation

Verify your approach

Check Your Understanding

Which swap implementation is correct?

  1. A.void swap(int& a, int& b) { a = b; b = a; }
  2. B.void swap(int a, int b) { int t = a; a = b; b = t; }
  3. C.void swap(int* a, int* b) { int t = a; a = b; b = t; }
  4. D.void swap(int& a, int& b) { int t = a; a = b; b = t; }
Start the roadmap to answer the quizzes and solve the challenges