C++ "Complete the code" Questions:
(A)
Finish implementing the swap function given below. Your
function should swap the integer values indirectly pointed to by
the two integer address parameters.
void swap(int *foo, int *bar)
{
int temp = *foo;
*foo = *bar;
*bar = temp;
}
(b)
Write a function based on the following
instructions/specifications:
Return type of void
Name of doubleVal
Has 1 parameter
Parameter is an integer pointer
You can name it whatever you want
The function should use the parameter variable to double the
integer value it indirectly points to
void doubleVal(int *ptr)
{
*ptr = *ptr * 2;
}
(c)
Given the following function, rewrite it to accomplish the same
functionality, with the change that the single parameter is an
integer pointer instead of an integer reference.
Do not change the function return type or attempt to use global
variables.
void getNumber(int *num)
{
cout << "Enter a number: ";
cin >> *num;
}
PLEASE DO NOT REPOST ANSWERS