(a) Consider the code fragment given below: ``` a : integer procedure f1(b: integer) b:= 5 Print a ... a:= 10 f1 (a) print a ``` Differentiate among the terms call-by-value, call-by-reference and call-by-value / result. Explain the output for the above code for call-by- value, call-by-reference and call-by- value / result. $\mathbf{1 5}$

Explanation

In call-by-value, the value of a is passed to the function f1, so a remains 10. In call-by-reference, the reference of a is passed to the function f1, so a becomes 5. In call-by-value/result, the value of a is passed to the function f1, but the result is not returned, so a remains 10.


โฌ† Related Topic

View Topic Hub โ†’

๐Ÿ“˜ Syllabus

View KERALA UNIVERSITY Class 6 Syllabus โ†’

๐Ÿ“ Practice Questions

Practice Previous Year Questions โ†’

๐Ÿค– Practice with AI

Generate Practice Question Paper โ†’


๐Ÿ“š Related Concepts