Please I need help with this C 1 What does pass by value do

Please.... I need help with this..

C++

*******************************************************************************************

1) What does pass by value do ?

2) What does pass by reference do ?

3) If you has an array of 100 elements, which is easier

Defining a function with 100 different variables so you can pass all elements of an array into it

Defining a function what passes just the location of the array, and you use the original array.

4) Would you rather pass 100 or Pass one value into a function ? How is this like a concept ?

Solution

1) Let us take an example int i = 9; From this passing the value means that you pass the actual value of the variable into the function. So in this example, it would pass the value 9.

2) From the above taken example passing by reference means that you pass the variable itself into the function (not just the value). So, in this example, it would pass an integer object with the value of 9.

3) The easier method is to define a function which passes just the location of the array,so that you use the original array.

4) Based upon the requirement we can pass 100 and also we can pass only one value in the function.

Please.... I need help with this.. C++ ******************************************************************************************* 1) What does pass by value do

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site