Call by Value VS Call by Reference.. Which is better?

Mintu Konwar
1 min readFeb 16, 2019

--

(i) Call by Value passes a copy of the original argument to the function and if any modifications is made on these arguments then it will not be reflected on the actual variable.

(ii) In Call by Reference, the memory address of the variables are passed so if any changes is made, the actual value stored at that memory location will also change.

According to me both are better as both have their own purposes. If we want to perform an operation on a variable without modifying the value of original, then Call by Value is preferred. If we want to perform an operation on variable and at the same time we want to update the original value then Call by Reference is preferred.

--

--

Mintu Konwar
Mintu Konwar

Written by Mintu Konwar

A third-year MCA student at Dibrugarh University with an interest in cybersecurity, software development, IT, and Machine Learning.

No responses yet