Week 2 Objectives


At the end of this week's classes you should

KNOW:

BE ABLE TO:

Sample Quiz Questions:

  1. Given this function description:

    The function named Volume uses a char called shape and two floats called dimension1 and dimension2 to determine the volume of a geometric shape. It is assumed that upon entry to the function, the value of shape is either 'C', 'Y', or 'T' (for cone, cylinder, or torus). It is also assumed that the values of dimension1 and dimension2 are greater than 0.0.

    1. Draw the function as a "black box" with inputs and outputs shown as labelled arrows. Indicate the data type associated with each arrow.
    2. Write a prototype for this function.
    3. Write a pre-condition for this function.
    4. Write the function as a stub.

  2. What will be displayed when the following program executes?
    #include <stdio.h>
    
    void changeVars (int x, int y);
    
    int main()
    {
      int a=4, b=5;
      printf ("a = %d, b = %d\n", a, b);
      changeVars (a,b);
      printf ("a = %d, b = %d\n", a, b);
      return 0;
    }
    
    void changeVars (int x, int y)
    {
      x = 10;
      y = 20;
      printf ("x = %d, y = %d\n", x, y);
      return;
    }
    
  3. In a short, well-written paragraph, define the terms scope and storage class.