Starting from:

$21

Programming Exercise Solution

9. Explain the difference between function parameters, local variables, and global variables regarding the parts of a program that can access these values.

10. What does void signify when used as the return type of a function?

 

11. What is the output of the following program fragment:

void find(int a, int& b, int& c)
{
int temp;
c = a + b;
temp = a;
a = b;
b = 2 * temp;
}

int main()
{
int x, y, z;

x = 15;
y = 25;
z = 30;

find(x, y, z);
cout << x << " " << y << " " << z << endl;
find(y, x, z);
cout << x << " " << y << " " << z << endl;
find(z, y, x);
cout << x << " " << y << " " << z << endl;
}

 

12. Write a C++ function which initializes its three reference parameters. The function should take an int, double, and string parameter and initialize them to 0 and the empty string ("").

More products