...
Algorithms
October 12, 2023
Algorithms
October 12, 2023
Algorithms
October 12, 2023
Algorithms
October 12, 2023

Algorithms

Question 37

In which one of the following cases is it possible to obtain different results for call-by reference and call-by-name parameter passing methods?

A
Passing a constant value as a parameter
B
Passing the address of an array as a parameter
C
Passing an array element as a parameter
D
Passing an array following statements is true
Question 37 Explanation: 
Passing an array element as a parameter then it gives different output values for the call-by-reference and call-by-name parameters.
{ ……..
a[ ] = {1, 2, 3, 4}
i = 0
fun(a[i]);
print a[0];
}
fun(int x)
{
int i = 1;
x = 8;
}

O/p:
Call-by-reference = 8
Call-by-value = 1

Correct Answer: B
Question 37 Explanation: 
Passing an array element as a parameter then it gives different output values for the call-by-reference and call-by-name parameters.
{ ……..
a[ ] = {1, 2, 3, 4}
i = 0
fun(a[i]);
print a[0];
}
fun(int x)
{
int i = 1;
x = 8;
}

O/p:
Call-by-reference = 8
Call-by-value = 1

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!