Question SOLVED: Based on the above the answer, which of the following two function prototypes makes sense to use for a function that will swap two values, the first or second?________________________________________

$30.00

Category:

Description

Question SOLVED: Based on the above the answer, which of the following two function prototypes makes sense to use for a function that will swap two values, the first or second?

  1. Based on the above the answer, which of the following two function prototypes makes sense to use for a function that will swap two values, the first or second?
    void swap(int val1, int val2); //prototype #1
    void swap(int& val1, int& val2); // prototype #2
    8. Write a function definition as follows: it returns the C++ form of a Boolean value, its function identifier is anyTwoTheSame, it has three formal parameters which all are floating-point values, and the body of the function returns true if any two of the parameters are equal, otherwise it returns false. I recommend using short, simple identifiers for the three formal parameters.
    9. (yes/no) In C++, is it legal to declare the variable int v; at the top of the body of a function and later declare char v; inside of a while loop body? (Book review question on scope.)
    //example function body template
    {
    int v;

    while(…)
    {
    char v;

    }

    }
    Answer:
    10-13. Consider the following function definition: void defaultParam(int num1, int num2 = 7, double z = 1.5){ int num3; num3 = static_cast<int>(z) + num2 – num1; cout << “num3 = ” << num3 << endl;}What is the output of the following function calls?10. Case one: defaultParam(7);
    Output:
    11. Case two: defaultParam(-7, -8);
    Output:
    12. Case three: defaultParam(0, 1, -7.5);
    Output:
    13. Case four: defaultParam(4, -4, -1.3);
    Output:

error: Content is protected !!