The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+1 vote
60 views
Are Call by Value and Pass by Value synonyms?

What are the differences between Pass by Value and Pass by Reference?

Please explain with examples.
in Programming by (259 points) | 60 views

1 Answer

+2 votes
Best answer
Here we are passing the values x and y in swap() calling function. So it is call by value or pass by value.

Yes both pass by value and call by value are similar.

In this first program we are passing the x and y values through swap() calling function. So it is called as Call by value or pass by value.

In the second program we are passing the addresses of x and y memory locations to the pointers a  and  b. If you observe here x and y addresses are also values. so it is also called as call by value. But so many of them assume this second program as an example for call by reference.

by (183 points)
selected by

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,339 questions
55,763 answers
192,337 comments
90,771 users