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

What is the best way to prepare for class 10?
First you need a time management. Prepare a well suitable time table including your shooling time accordingly. Allot certain time form each and every subject. Follow the time table without fail daily....
Naveeen
0 0
5
Should I study BTech or BSc?
If you are desperate about job , you have to go for btech in good college.bsc is also good but after doing this you have to go for further degrees for getting job.
Yuvraj
0 0
5
Hi.. I'm 3rd year student,My spoken English is not too good.
Your English is not too good. But little good right. So you are not a starter. No need for coaching classes. Built confidence in yourself. Talk in English with yourself & others. Read English newspaper....
Indrajeet
What are the future prospects of doing a BTech in marine engineering from Indian Maritime University?
You will be able to apply your knowledge which you have gained at the university to solve real-world problems in the marine industry and also develop new and innovative projects in this field. You may...
Preeti
0 0
6

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

Ask a Question

Related Lessons

Test On Thermo
All perfect gases change in volume by 1/273th of its original volume at 0°C for every 1°C change in temperature, when the pressure remains constant. This statement is called (A) Boyle's law (B)...

E-magazine
E-magazine is a magazine published on the World Wide Web. Some online magazines may refer to themselves as electronic magazines or e- magazine to reflect their readership, demographics or to capture alternative...

Java 9 , the new beginning
Java 9 is here! A major feature release in the Java Platform Standard Edition is Java 9 Lets see what more it offers more than its previous versions Java platform module JEP 223 : New version...
G

GCC

0 0
0

Components of Digital Marketing
Content marketing Search Engine Optimization (SEO) Paid Search (PPC) Email marketing Social Media Marketing Digital Display Marketing (Ad Ops) Web Analytics and Reporting Mobile Marketing 30...

7 -WAYS THAT CAN IMPROVE THE LIFE OF A STUDENT
1. Classroom attentionSometimes #students loose their concentration in to the #classroom and not grasp the topic properly and hence loose their interest in to subject (s). As a result bad score bad performance....
D

Dr

1 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