Swap function in Selection_Sort function

There was no swap function defined beforehand and is being used in the selection sort function. Is it a library function?
Or even if we are to make it ourselves why is the value of the two elements of array being passes? Shouldn’t we pass the indices and the array itself??

Yes it is a predefined function and you can use it. You can read about it here:

Say you want to swap arr[1] and arr[4]…so you can use the statement
swap(arr[1],arr[4])