CS 1440 pre-lab activities for Lab Extra (2)

You have 5 minutes to answer these questions.

Answer the following questions in writing before you begin the lab and hand in the solution to your instructor.
1. What will the following code segment display? Assuming that the rest of the program is correct.

      int func(int& z);
      int main() 
          int x=3, y=2; 
          x = func(y); 
          cout << "x = " << x  << "   and y = "  << y  << endl;
          return 0; 

      int func(int& z) 
           int x = 0; 
           x = z*z; 
           return z/2; 
2. Suppose you want to write a function to compute the following formula.  Fill out the blanks below the formula.
This basically means that the average is the sum of N values (i2) divided by the number of values.

Function Name: ___________________ Function Type: ____________________

Function argument(s): __________________

Return value (if it is not a void function) : ______________________________

The function prototype: ______________________________________________

3. Consider the function prototype for function myfunction and assume that the following segment is placed in a complete program.  What is wrong with this code segment? 
       void  myfunction(int x);

       int main()
        int x,y;
        cout << myfunction(x) << endl;

        return 0;