The following function should swap the values contained in two integer variables, num1 and num2. What, if anything, is wrong with this function?
void swap(int num1, int num2)
{
int temp = num2;
num2 = num1;
num1 = temp;
}
You must first initialize temp to 0 before using it.
The variable temp should first be set to num1, not num2.
The swap function must use reference parameters.
The last line should be temp = num1.
Nothing is wrong with this function.