1 answer

For each of the following function calls, please write if the parameter is passed by value...

Question:

For each of the following function calls, please write if the parameter is passed by value or passed by reference to a hypothetical function 'myFunc'. You should briefly explain why to get full credit.

Q7.1

3 Points

int num = 5; myFunc(num);

Q7.2

3 Points

int num = 5; myFunc(&num);

Q7.3

3 Points

int num[] = {5}; myFunc(num);

Q7.4

3 Points

int num[] = {5,6,7,8,9}; myFunc(num);

Q7.5

3 Points

char name[6] = "Hello"; myFunc(name);


Answers

ANSWER

Q7.1

int num = 5;

myFunc(num);

Ans -)

It is pass by value not reference in this we just pass num which is recieved by another variable in the myFunc() which is a copy of num value.

Q7.2

int num = 5;

myFunc(&num);

Ans -)

It is passed by reference.

Because in parameter passing &num is passed which means the address of num variable is passed. So it is not a copy any changes in that address value also reflect in the num.

Q7.3

int num[] = {5};

myFunc(num);

Ans -)

It is passed by refrence.

Whenever we pass the array to the function it is pass by refrence.

When we pass the array then the refrence of array is passed so changes in different array reflects the changes in the original array also.

Q7.4

int num[] = {5,6,7,8,9};

myFunc(num);

Ans -)

It is also a passed by refrence.

Whenever we pass the array to the function it is pass by refrence.

When we pass the array then the refrence of array is passed so changes in different array reflects the changes in the original array also.

Q7.5

char name[6] = "Hello";

myFunc(name);

Ans -)

It is also a passed by reference.

Because value passed with array is pass by reference.

If any changes in the passed array will also reflect in the original array.

.

Similar Solved Questions

1 answer
Han Products manufactures 45,000 units of part 5-6 each year for use on its production line....
Han Products manufactures 45,000 units of part 5-6 each year for use on its production line. At this level of activity, the cost per unit for part S-6 is as follows Direct materials Direct labour Variable overhead Fixed overhead $ 5.00 11.00 4.00 9.90 Total cost per part $29.90 An outside supplier h...
1 answer
Explain the need for health promotion with the pregnant patient and identify two important health promotion...
Explain the need for health promotion with the pregnant patient and identify two important health promotion concerns for pregnant women. Explain what information you would provide to these patients in a clinical setting....
2 answers
In "A White Heron," having made her choice between an attraction of the heart and her bond with nature, Sylvia A
In "A White Heron," having made her choice between an attraction of the heart and her bond with nature, Sylvia A. retains her loyalty to nature and becomes more suspicious of human nature. B. retains her loyalty to nature as her affection for the hunter grows. C. is able to experience a la...
1 answer
Person A is running North at 5 m/s and Person B is running North at 8...
Person A is running North at 5 m/s and Person B is running North at 8 m/s parallel to the y axis. The paths of person A and person B have a horizontal distance (along the x axis) of 10 feet between them. Person A can throw a ball at 20 m/s. What angle does person A need to throw the ball relative to...
1 answer
Problem #2 You have a 1000 W electric motor connected to a 200 Vms, 60 Hz...
Problem #2 You have a 1000 W electric motor connected to a 200 Vms, 60 Hz source, and the resulting power factor is 0.8 lagging. (Hint: Based on the units, is power rating of the motor real power or apparent power?) a. What is the voltage in terms of a phasor? b. By how many degrees does the current...
1 answer
You are reading about a garden designer who has invented something called the "megagarden space" in...
You are reading about a garden designer who has invented something called the "megagarden space" in which a few specimens are planted in a disturbed area and allowed to make a garden by self-propagation. Why might this designer choose to work with angiosperms rather than gymnosperms? Multipl...
1 answer
A gas mixture contains 9.60 g of N2, 2.80 g of H2 and 13.8 g of...
A gas mixture contains 9.60 g of N2, 2.80 g of H2 and 13.8 g of CH4. What is thr mole fraction of H2 in the mixture? A gas mixture contains 14.0 g of N2, 2.40 g of H2 and 19.4 g of CH4. What is the mole fraction of CH4 in the mixture?...
1 answer
Zira Co. reports the following production budget for the next four months. Production (units) April 662 May 690 June 69...
Zira Co. reports the following production budget for the next four months. Production (units) April 662 May 690 June 696 July 676 Each finished unit requires four pounds of raw materials and the company wants to end each month with raw materials inventory equal to 30% of next month's production ...
1 answer
Problem 1: A coach needs to choose two of his three swimmers to be assigned to...
Problem 1: A coach needs to choose two of his three swimmers to be assigned to a race that requires one swimming butterfly and the other one Jack 20 swimming free style. How can he pick the two that minimizes the total swimming time for the team? im 30 35 Joe 40 45 Butterfly Free style50 a) b) Write...
1 answer
Physical Chemistry Please help 4) Consider the following reaction at 298.15 K: H2(g) +12(g) = 2HI(g)...
Physical Chemistry Please help 4) Consider the following reaction at 298.15 K: H2(g) +12(g) = 2HI(g) a. Determine Agirn and Kp for this reaction if a mixture contains 2.82 bar HI and 0.0909 bar H2 and 12 at equilibrium. b. Determine the equilibrium concentrations if 0.0100 bar H2 and 0.0100 bar 12 ...
1 answer
Stats leab 9.1 Hypothesis Testing of a Single Mean and Single Proportion Class Time: Names: Student...
Stats leab 9.1 Hypothesis Testing of a Single Mean and Single Proportion Class Time: Names: Student Learning Outcomes • The student will select the appropriate distributions to use in each case. The student will conduct hypothesis tests and interpret the results. Television Survey In a recent s...
1 answer
Biology ercise 1: Using a Light Microscope: 1. Fill out this table to calculate total magnification...
Biology ercise 1: Using a Light Microscope: 1. Fill out this table to calculate total magnification using different objectives: Total Magnification Name of Objective Scanning Low Power High Power Oil Immersion Objective Magnification 4x 10x 40x 100x 1. Use these data to answer the questions: ...
1 answer
6. Let f(x,y) = 1 if 0 < y < 2x, 0<x<1, and 0 otherwise. Find...
6. Let f(x,y) = 1 if 0 < y < 2x, 0<x<1, and 0 otherwise. Find the following: a) f(y|x) b) E(Y|X = x) c) The correlation coefficient, p, between X and Y...
1 answer
7. (Norms of outer products) Find an expression relating the norm of the outer product |uv||...
7. (Norms of outer products) Find an expression relating the norm of the outer product |uv|| to the norms of the vectors uand || v |...
1 answer
How do I find the length of the specified arc of the given curve? y^2=x^3 between (0,0) and (4,8)
How do I find the length of the specified arc of the given curve? y^2=x^3 between (0,0) and (4,8)...
1 answer
These trends from common size statements For Walmart INC, what conclusions can you draw from them?...
These trends from common size statements For Walmart INC, what conclusions can you draw from them? Walmart Inc. Income statement : - Walmart Inc.'s operating income as a percentage of net sales declined from 2016 to 2018 by 5.04% (2016), 4.73% (2017), 4.12% (2018). The income from continuing ope...
1 answer
No Spacing Heading 1 Heading 5. [6 points] Use the process illustrated in the Guided Lecture...
No Spacing Heading 1 Heading 5. [6 points] Use the process illustrated in the Guided Lecture Notes and on page 360 of the eText to write each of the following as a fraction in simplest form. a 0.85 b. 1.362 • 3.41...
1 answer
Ch 9 Q 39 Which is expected to have the largest carbom-oxygen bond dissociation energy? -HCOOH...
Ch 9 Q 39 Which is expected to have the largest carbom-oxygen bond dissociation energy? -HCOOH -H2CO3 -CO2 -CO 9.106 Use the bond dissociation energies from the table provided to calculate an approximate standard enthalpy in kilojoules for the reaction of ethylene with hydrogen to yield ethane P...