Solved

The Following Function Should Swap the Values Contained in Two

Question 24

Multiple Choice

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;
}


A) You must first initalize temp to 0 before using it.
B) The variable temp should first be set to num1, not num2.
C) The swap function must use reference parameters.
D) The last line should be temp = num1.
E) Nothing is wrong with this function.

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents