Home » C++ Programming » Introduction » Question
  1. What is the new value of P?
    #include 
    using namespace std;
    void function(int &p)
    {
    p = 15;
    }
    int main()
    {
    int p = 12;
    function(p);
    cout << "New value of P is " << p;
    return 0;
    }
    1. New value of P is 12
    2. Compilation Error
    3. New value of P is 15
    4. Runtime Error
    5. None of these
Correct Option: C

As we passed by reference, the value is changed and it is returned as 15.



Your comments will be displayed only after manual approval.