CS 1440 pre-lab activities for Lab 5

Before coming to the lab, you should answer the following questions in writing.

1. Write a C++ program that asks users for two entries of type double, x and y, and then it displays their products.  Your code should have:
    1) a function called get_x that asks the users for the value of x, then returns x to the main function.
    2) a function called get_y that asks the users for the value of y, then returns y to the main function.
    3) a function called mult_xy that takes x and y as its parameters and returns their product to the main function.

Your program must use all three functions.

2. We mentioned that a function can only return one value using the return statement.  Is there any way that a function returns more than one value?  In the above program, could you return both x and y from one function, let's say get_xy?

3. Can a function call another function? Maybe this helps you answer this question.
In the following program, is main a function? Does it call another function?


float divide_xy(int x, int y);

int main(void)
      int x,y;
      float qt;

      cout << "Enter 2 values for x and y separated by space, then press <Enter> :";
      cin >> x >> y;
      cout << endl;
      qt = divide_xy(x,y);

      cout << x << "/" << y << " = " << qt << endl;

      return 0;

float divide_xy(int x, int y)
      return float(x)/y;