Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

a).Write a function called Doubling with a void return type, which has only a si

ID: 3563530 • Letter: A

Question

a).Write a function called Doubling with a void return type, which has only a single reference parameter, i.e., will be called by reference such that when the function is called say from main(), the value of the arguement submitted, upon its completion, will become twice as much as its value before the function is called. Assume the arguement datatype is int.

b).Write another function equivalent to the one above except that
it will be called by value (instead of by reference), and will
also have a single value-parameter. The return type is also a
void for the new function. Use the same name for this function
as in part(a).

Explanation / Answer

a).Write a function called Doubling with a void return type, which has only a single reference parameter,
i.e., will be called by reference such that when the function is called say from main(),
the value of the arguement submitted, upon its completion, will become twice as much as its value before
the function is called. Assume the arguement datatype is int.

void Doubling(int& number){
number = 2*number;
}

b).Write another function equivalent to the one above except that
it will be called by value (instead of by reference), and will
also have a single value-parameter. The return type is also a
void for the new function. Use the same name for this function
as in part(a).

void Doubling(int number){
number = 2*number;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote