UrbanPro

Take BTech Tuition from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

What is the difference of pass by value and pass by reference?

Asked by Last Modified  

Follow 0
Answer

Please enter your answer

Computer science

Pass by value:----just suppose u have a note copy(fair copy) . Your friend ask you to give your copy. You just xerox your fair copy and give to your friend. After that he/she edit on your xerox copy. Show there will be no change in original copy. Same in function also value is copy and all the...
read more
Pass by value:----just suppose u have a note copy(fair copy) . Your friend ask you to give your copy. You just xerox your fair copy and give to your friend. After that he/she edit on your xerox copy. Show there will be no change in original copy. Same in function also value is copy and all the work done on copy value(xerox copy). Call by reference:--- You just given your original copy. so if any change done is done on your original copy. mean u pass the address of original variable. So all change done on original one(note copy). read less
Comments

Make you shine in programming

Say I want to share a web page with you. If I tell you the URL, I'm passing by reference. You can use that URL to see the same web page I can see. If that page is changed, we both see the changes. If you delete the URL, all you're doing is destroying your reference to that page - you're not deleting...
read more
Say I want to share a web page with you. If I tell you the URL, I'm passing by reference. You can use that URL to see the same web page I can see. If that page is changed, we both see the changes. If you delete the URL, all you're doing is destroying your reference to that page - you're not deleting the actual page itself. If I print out the page and give you the printout, I'm passing by value. Your page is a disconnected copy of the original. You won't see any subsequent changes, and any changes that you make (e.g. scribbling on your printout) will not show up on the original page. If you destroy the printout, you have actually destroyed your copy of the object - but the original web page remains intact read less
Comments

C, linux kernel

Pass by value will just copy the value of the variable to function argument whereas, pass by reference will send the address of the variable to the function argument. So, the changes you do in the function will be reflected in the caller function in case of pass by reference.
Comments

BE(all subject) and 12th biology,maths,tamil,english,physics,chemistry.

Passing by reference : the called functions' parameter will be the same as the callers' passed argument, Pass by value : the called functions' parameter will be a copy of the callers' passed argument.
Comments

Using pass by value we pass the values using variables where as pass by reference we pass adresses of variables.
Comments

Every variable that you create in your code requires some memory (on RAM) to store its value. For example, when you create an integer in C++, the system reserves 2 bytes in RAM to store the value of the integer. Every variable can be located internally by the system using an address called memory-address...
read more
Every variable that you create in your code requires some memory (on RAM) to store its value. For example, when you create an integer in C++, the system reserves 2 bytes in RAM to store the value of the integer. Every variable can be located internally by the system using an address called memory-address (it is a binary number). If you want to pass a variable as a functions argument, there are two ways, it can be done: 1) Pass by value. Here the value of the variable being passed is copied into the function's parameter variable. Example: Suppose we have a function void add(int a, int b); In main function, we call the function such as: int x = 5, y = 6; add(x, y); Now here, when the function is called, the values of x and y (5 and 6) are copied into the function's parameters a and b. This means that if you change the values of a and b inside the function's code, then x and y are not affected. 2) Pass by reference When we pass a variable by reference the address of the variable being passed is copied into the function's parameter. Example: Suppose we have a function void add(int &a, int &b); In main function, if we call it using the same code: int x = 5, y = 6; add(x,y); then, only the reference of x and y will be passed to a and b instead of copying the values. Hence, a and b will use the same memory location of x and y to access or change its values. This means that if you change the value of a inside the function, then it will change the value of variable x of main function. Similarly changing value of b will change y of main. Long answer, but I hope I have managed to explain you the difference. Feel free to contact me if you have any doubts. :) read less
Comments

Software Developer and Trainer with 10 years of experience

Both Pass by Value(Call by value) and Pass by Reference(Call by reference/address) are the two methods to call a function. Let me explain them so that we can easily identify the difference. In pass by value, You call a function by directly passing the value of the arguments. The values will be...
read more
Both Pass by Value(Call by value) and Pass by Reference(Call by reference/address) are the two methods to call a function. Let me explain them so that we can easily identify the difference. In pass by value, You call a function by directly passing the value of the arguments. The values will be copied by the called function and all statements in that function will work on those copied values only. Thus this method of calling will not modify originally passed values. In pass by reference, You call a function by passing the references (memory address) of original values. This reference will be received in pointers by called functions. Through the pointers, the called function work on the values that are stored in those memory addresses. Thus this method of calling will modify the original values itself. In simple, If you call by value, the passed values will be duplicated and called function will work on that duplicate values. So original values will not be affected. If you call by reference, the passed addresses will be directly accessed through pointers. This cause modification of original data. read less
Comments

Shine

pass by value means we are passing a a copy of the value of each argument is passed to the function;and passed by referance means we are passing an address to a function.
Comments

B.E., M.Tech

1) In pass by value, the value of the arguments (actual parameters) are copied to the formal parameters whereas in pass by reference, the address of the arguments (actual parameters) are copied to the formal parameters. 2) In pass by value, changes to the formal parameters won't alter the value of...
read more
1) In pass by value, the value of the arguments (actual parameters) are copied to the formal parameters whereas in pass by reference, the address of the arguments (actual parameters) are copied to the formal parameters. 2) In pass by value, changes to the formal parameters won't alter the value of the arguments (actual parameters) whereas in pass by reference, changes to the formal parameters alter the value of the arguments (actual parameters) read less
Comments

Software Devloper

In pass by value approach, the called function creates another copies of the variables passes as arguments. In this approach, the values of the original variables remain unchanged. However, we come across situations where we need to change the values of the original variables. Then the values may b passed...
read more
In pass by value approach, the called function creates another copies of the variables passes as arguments. In this approach, the values of the original variables remain unchanged. However, we come across situations where we need to change the values of the original variables. Then the values may b passed by reference read less
Comments

View 11 more Answers

Related Questions

Which are the best private colleges for a BTech (CSE) in Delhi NCR?
JSS NOIDA AKG GAZIABAD KIET GHAZIABAD GALGOTIA GR NOIDA GNIOT GR NOIDA
Jitendra
0 0
5
What is Electronics ANd Communication Engineering?
ELectronics and Comm Engg is about the electronic design and how this can be applied in communication like mobile communication, antena, wave porpogation, signals logic design etc........
Maunish
what is the java programming course fee and duration time?
learn basic java programme will take around 1-2 month and fee around 2K-3K. better go with basic+advanced java , it will worth by learning as well as fee wise.
Deepak
I am persuing my graduation in mechanical and production department .I am interested to write gate 2017.Is there any one to guide me?
Hi Rajesh,its nice to know you are willing to write GATE exam. Let me tell you first more than any coaching first make up your mind set that you have to clear it, and try to learn the basic concepts. Once...
Rajesh

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Methodology of Learning - specially mathematics
tt ALWAYS TAKE THE HELP OF THE INTERNET. EXCELLENT REFERENCE MATERIAL IS AVAILABLE HERE IN PRACTICALLY EVERY SUBJECT THAT YOU CAN THINK OF. DO NOT WITH ONLY ONE SITE, GO TO AS MANY SITES AS POSSIBLE...

Want to expertise in your subjects, here is a tip ?
The best way to expertise in your subject is by having the practical knowledge of it. Once your concepts are clear in practicals, then while studying you'll understand the difference between ideal and...

Finding a Majority Element
Problem Description Task. The goal in this code problem is to check whether an input sequence contains a majority element. Input Format. The first line contains an integer, the next one contains a sequence...

STUDY TIP
EAT TULSI LEAVES EVERY MORNING AND DRINK WATER AFTER THAT

Economics: A Multi Tasking Tool Set In Any Form Of Business With Profit Or Cba Score
Economics is age-old subject started in Greek or Roman era 15th or 16-century b.c. It was defined initially as money or money making as early mercantilist said or beneficial gold or silver as latter mercantilists...

Recommended Articles

MBA, Medicine and engineering are the three main professional courses in India. Engineering is still one of the highly sorted after professional courses in the under graduate level, while MBA is favoured as a preferred post graduate course. To shine in these courses, one needs to work and study hard. Engineering as a...

Read full article >

According to a recent survey conducted by the NCAER (National Council of Advanced Economic Research), engineering is the most sought after course in India. Some engineering courses are offered as BE or Bachelor of Engineering while some as Bachelor in Technology or B.Tech. Since engineering is a professional course, the...

Read full article >

E-learning is not just about delivering lessons online. It has a much broader scope that goes beyond manual paper or PowerPoint Presentations. To understand the reach of E-learning and how the whole process works in developing the Educational system, we will discuss a few points here. Let us find out how this new learning...

Read full article >

With the mushrooming of international and private schools, it may seem that the education system of India is healthy. In reality, only 29% of children are sent to the private schools, while the remaining head for government or state funded education. So, to check the reality of Indian education system it is better to look...

Read full article >

Looking for BTech Tuition ?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for BTech Tuition Classes?

The best tutors for BTech Tuition Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Take BTech Tuition with the Best Tutors

The best Tutors for BTech Tuition Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more