The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+1 vote
57 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.
asked in Programming by (253 points) | 57 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.

answered by (175 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
49,808 questions
54,481 answers
188,247 comments
74,517 users