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

1. For each of the parameter passing methods what are the values of the list arr

ID: 3537243 • Letter: 1

Question

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

a) 1. Pass by value

b) 2 Pass by reference

c) 3.   Pass by value result

#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

A) Pass by value
list contains 1 3

B) Pass by reference
list contains 2 6

C) Pass by value-result
list contains 2 6