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

Why D.C drives are preferred in various industries even if the supply was A.C?
It depends upon torque requirment where high torque application is needed DC drives is used
Saikrishna
0 0
7
Can a second year BTech student take tuition for classes 9 and 10?
Yes , definitely because this time 2nd year students have enough time so then can take easily tuition for class 9 10 .
Ashok
0 0
8
Is coaching important for the class 12 science exam?
No need. The thing is you must have basics and be upto date in reading and learning. Just need a compressuve reading of lessons as many times as possible and practice bits questions. It is enough to get good result.
Mrinal Kanti
0 0
5
Which is better, a BTech or a Dual Degree from an IIT?
Dual Degree. But since those are very rare depending upon the oferring from a Campus.
K
0 0
5

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

Ask a Question

Related Lessons

Boolean Algebra
Logic Simplification Simplification of Boolean functions is mainly used to reduce the gate count of a design. Less number of gates means less power consumption; sometimes the circuit works faster and...

Mechanical Engineering Capsules.
1. Reversible adiabatic process is always Isentropic but the reverse is not always true. 2. Stress is a second order tensor quantity. 3. Steels have higher melting point than cast irons i.e. why they...

Atterberg's Limits
Atterberg's Limits are proposed by US crop Engineer Atterberg. These are water contents which assert the soil behaviour. 1. Liquid Limit 2. Plastic Limit 3. Shrinkage Limit. Liquid Limit: It is...
A

Andhe Venkatesh

0 0
0

Oncolytic virotherapy
Oncolytic Virotherapy: Measles Virus as an agent of tumour destruction Oncolytic Viruses- Viruses that replicate selectively in tumour tissues and lyse the tumour cells Virotherapy Benefits (Attenuated...

The Strategies that Set Top Students Apart
Study Tips 1: Focus on mastery Study Tips 2: Find the value for you Study Tips 4: Build your competence and gain confidence Study Tips 5: Think critically about what you’re learning Study Tips...

Piyush Chauhan

0 0
0

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 >

With the current trend of the world going digital, electronic renaissance is a new movement that is welcomed by the new generation as it helps makes the lives of millions of people easier and convenient. Along with this rapidly changing movement and gaining popularity of Internet, e-Learning is a new tool that emerging...

Read full article >

While schools provide formal education to the children, the home is where they start learning about things informally. Parents think that schools will take the initiative to educate their children. Well, this is partially true, as parents also play an essential role in bringing up their child. For the development of particular...

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