1.Consider the following program written in C syntax: void fun ( int first, int
ID: 3559910 • Letter: 1
Question
1.Consider the following program written in C syntax:
void fun (int first, int second) {
first += first;
second += second;
}
void main() {
int list[2] = {1, 3};
fun(list[0], list[1]);
}
If the fun subprogram uses "pass by value" parameter-passing method, what are the values of the int array "list" after the call to fun within main?
list = {1, 1}
list = {1, 3}
list = {3, 3}
list = {2, 6}
2. Consider the following program written in C syntax:
void fun (int first, int second) {
first += first;
second += second;
}
void main() {
int list[2] = {1, 3};
fun(list[0], list[1]);
}
If the fun subprogram uses "pass by reference" parameter-passing method, what are the values of the int array "list" after the call to fun within main?
list = {1,1}
list = {1,3}
{list = {3,3}
list = {2,6}
a.list = {1, 1}
b.list = {1, 3}
c.list = {3, 3}
d.list = {2, 6}
Explanation / Answer
a) values of list array has not changed so right option is b
b) in this value will change so right option is d
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.