Introduction


  1. If the user did not supply the value, what value will it take?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    If the user did not supply the value means, the compiler will take the given value in the argument list.


  1. Where can the default parameter be placed by the user?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    rightmost



  1. Which value will it take when both user and default values are given?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    The default value will be used when the user value is not given, So in this case, the user value will be taken.


  1. What is the output of this program?
    #include 
    using namespace std;
    void function(int p, bool condition = true)
    {
    if (condition == true )
    {
    cout << "Condition is true. P = " << p;
    }
    else
    {
    cout << "Condition is false. P = " << p;
    }
    }
    int main()
    {
    function(250, false);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    In this program, we are passing the value, as it evaluates to false, it produces the output as following.



  1. What is the output of this program?
    #include 
    #include
    using namespace std;
    string askMessage(string Message = "Please enter a message: ");
    int main()
    {
    string Input = askMessage();
    cout << "Here is your message: " << Input;
    return 0;
    }
    string askMessage(string Message)
    {
    string Input;
    cout << Message;
    cin >> Input;
    return Input;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    In this program, we are getting a number and printing it.