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
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.