Question: The following function should swap the values contained in two integer variables, nom 1 and num 2 . What, if anything, is wrong with this

The following function should swap the values contained in two integer variables, nom1 and num2. What, if anything, is wrong with this function?
void swap (int num1, int num2)
{
int temp = nam2;
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.
The following function should swap the values

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!