CIS105 Fall 2003 Lab09

For Lab09 we are NOT doing the chapter from the lab manual. We are going to continue our study of functions for one more week before moving on to arrays.

Lab09 consists of three programs

  1. For Lab09a, write a function called printStarSquare that displays a square of stars at the left margin of the screen. The function should have one parameter, which is the size of the square. For example, if the number passed into the function is 5, the square printed should look like this:

    *****
    *****
    *****
    *****
    *****
    
    Include a main function in your file to test your function. The main should allow the user to enter a number, and then call your function with that number.

  2. For Lab09b, write a function called printSquare that works just like printStarSquare, except that this time, you have two parameters. One of the parameters will be a char variable that is the character you want to use to build the square.

    For example, if you call the function with

    printSquare(4, 'H')
    then the output would be:

    HHHH
    HHHH
    HHHH
    HHHH
    

    On the other hand, if you call the function with

    printSquare(3, 'I')
    then the output would be:

    III
    III
    III
    
  3. For Lab09c, write a function called printBox that works just like printSquare, except that this time, the character is printed only on the outline of the square. Your main should allow you to input a value for the size of the box, and the character to use to draw the box. For example:
    printBox(4, 'H')
    should produce:

    HHHH
    H  H
    H  H
    HHHH
    

    and

    printSquare(3, 'I')
    should produce:

    III
    I I
    III
    
To turn in: A single script file containing a "cat" of each of your programs, and then several runs of each of your programs. You should show that your program produces the correct output for 1, 2, 5, and then some other value that your choose. Grading is based on the criteria in Chapter 14 of the lab manual. The "A" grade part is the printBox part.
Phillip T Conrad
Last modified: Thu Oct 30 23:39:36 EST 2003