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

For each of the parameter passing methods what are the values of the list array

ID: 3569101 • Letter: F

Question

For each of the parameter passing methods what are the values of the list array after execution?

Pass by value

Pass by reference

#include <iostream>

using namespace std;

void fun(int a, int b);

void main()

{

          int list[2] = {1,3};

         

          fun(list[0],list[1]);

         

          cout << "list contains: ";

          for (int i = 0; i < 2; i++)

                    cout << list[i] << " ";

          cout << endl;

}

void fun(int first, int second)

{

          first += first;

          second += second;

}

Explanation / Answer

1 3 pass by value

2 6 pass by referrence