CISC105 Fall 2005 Lab05

For lab05 deals with functions and loops.

lab05 consists of three programs

  1. For lab05a, 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 lab05b, 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 lab05c, 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

    printBox(3, 'I')
    should produce:

    III
    I I
    III
    

To turn in: A single script file called lab05.txt containing a "cat" of each of your programs, evidence that your program compiles, 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 you choose.

Upload all three of your .c files plus your .txt file to WebCT.

Academic Honesty reminder: A reminder that you should work independently. You can share with each other by "discussing" the problem (away from the computers), but you may not copy code from one another, either by paper, or electronically, by looking at each other's screens, or by any other means. Doing so is a serious violation of academic honesty, and will be treated as such.

 


Phillip T Conrad