Home » C++ Programming » Functions » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    void duplicate (int& P, int& Q, int& R)
    {
    P *= 2;
    Q *= 2;
    R *= 2;
    }
    int main ()
    {
    int M = 2, N = 4, O = 6;
    duplicate (M, N, O);
    cout << M <<" "<< N <<" "<< O;
    return 0;
    }
    1. 4 8 12
    2. 12 8 4
    3. 8 12 4
    4. Compilation Error
    5. None of these
Correct Option: A

We are passing the values by reference and modified the data on the function block.



Your comments will be displayed only after manual approval.