DATA STRUCTURE
Programming and Technical
Logical Reasoning
Coding Decoding
Consider the following code:
function modify(w,u)
{
w = w + 2
u = u - 3
return (w - u)
}
function calculate( )
{
integer a = 10, b = 20, c
c = modify(a, b);
print a
print space
print b
}
Assume that a was passed by value and b was passed by reference. What will be the
output of the program on executing function calculate( ) ?
Op 1: 12 17
Op 2: 10 17
Op 3: 12 20
Op 4: 10 20
Read Solution (Total 8)
-
- option 2 10 17
- 7 years agoHelpfull: Yes(6) No(1)
- In pass by value, a copy of original data is send so no change in a's value.
But in pass by reference, address of original data is send and any change made in the passed parameters is reflected in the original data as well.
So, output will be a=10 and b=17 ,i.e, op 2. - 7 years agoHelpfull: Yes(6) No(0)
- As arguments are passed by value not by reference hence there is no change in a and b hence
the correct answer is op 4: 10 20 - 7 years agoHelpfull: Yes(3) No(0)
- 10,20 the arguments are passed by values not by references
- 6 years agoHelpfull: Yes(2) No(0)
- ANS:10 20
- 7 years agoHelpfull: Yes(1) No(1)
- option 4: 10 20
because we are passing values not reference - 6 years agoHelpfull: Yes(1) No(0)
- Op 2: 10 17
- 7 years agoHelpfull: Yes(0) No(0)
- Op 4: 10 20 run it in devc++
- 6 years agoHelpfull: Yes(0) No(1)
DATA STRUCTURE Other Question