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;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.