Home » C++ Programming » Introduction » Question
  1. What is the output of this program?
    #include 
    using namespace std;
    int function(int p = 12, int q)
    {
    int s;
    s = p + q;
    return s;
    }
    int main()
    {
    cout << function(15);
    return 0;
    }
    1. 15
    2. 12
    3. Runtime Error
    4. Compilation Error
    5. None of these
Correct Option: D

We can’t use the user argument in front of the default argument.
Compilation Error

In function 'int function(int, int)':
3:9: error: default argument missing for parameter 2 of 'int function(int, int)'



Your comments will be displayed only after manual approval.