Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#include<iostream> using namespace std; void fn(int a, int b) { a = 10; b = 20;

ID: 3839735 • Letter: #

Question

#include<iostream>

using namespace std;

void fn(int a, int b)

{

       a = 10;

       b = 20;

}

int main()

{

       int nValue1 = 1;

       int nValue2 = 2;

      

       fn(nValue1, nValue2);

      

       cout << " nValue1 = " << nValue1 << endl;

       cout << " nValue2 = " << nValue2 << endl;

       return 0;

}

What are the value of nValue1 and nValue2 after running the program above

1, 2

20,   10

10,   20

2,   1

a.

1, 2

b.

20,   10

c.

10,   20

d.

2,   1

Explanation / Answer

Answer : Option a ---> 1,2

* In main funtion initial values of nValue1 = 1 and nValue2 = 2.

* The line with function " fn(nValue1, nValue2) " in main goes to function definition line " fn(int a, int b) " and the

function does not return any value to " fn(nValue1, nValue2) ". So, the values in nValue1 and nValue2 does not

change. i.e,

nValue1 = 1

nValue2 = 2