What is the syntax of swap()?

a) swap(arr1, arr2);
b) arr1.swap(arr2);
c) swap<int, int>(arr1, arr2);
d) swap[arr1, arr2];

1 thought on “What is the syntax of swap()?”

  1. b
    Explanation: The correct syntax of swap function is arr1.swap(arr2) i.e. one array calling swap() function with second array as parameter to swap function. Also swap is a function therefore [] operator cannot be used to call swap function.

Leave a Comment