SI 204 Spring 2017 / HWs


Homework 10: Loops

Name: _____________________________________________ Alpha: ___________________

Describe help received: ________________________________________________________

  • Due before class on Friday, February 3
  • This homework contains code to be submitted electronically. Put your code in a folder called hw10 and submit using the 204sub command.
  • This is a written homework - be sure to turn in a hard-copy of your completed assignment before the deadline. Use the codeprint command to print out your code and turn that in as well.

Assignment

  1. Circle one to indicate how you did for the reading assignment from Homework 8 before class on Monday:

    How carefully did you complete the reading? (Circle one)

    Not at all
    Skimmed it
    Read some
    Read all
  2. Circle one to indicate how you did for the reading assignment from Homework 9 before class on Wednesday:

    How carefully did you complete the reading? (Circle one)

    Not at all
    Skimmed it
    Read some
    Read all
  3. The following is a standard set of questions to check your understanding of the collaboration rules in our course policy, and more generally the CS department instruction on programming projects.
    Circle all correct answer(s) to each question.
    1. You can collaborate with classmates in SI204 on this type of assignment, as long as the collaboration is cited on what you turn in.
      homeworks labs projects none of these
    2. Which of the following sources of assistance is always allowed, on any assignment?
      EI from your instructor help from other students your own class notes a binder of past assignments from an upperclassman
    3. Which kind(s) of assignments do you need to cite your sources on?
      homeworks labs projects none of these
    4. The collaboration rules for programming projects is the same as that for labs and homeworks.
      True False
    5. If you get a tip from an instructor on a programming project, you are free to share that tip with classmates.
      True False
    6. Which websites are okay to use on homeworks and labs?
      the course website links from the course website questions you asked on StackOverflow questions other people asked on StackOverflow other websites about C programming
    7. Which websites are okay to use on programming projects?
      the course website links from the course website questions you asked on StackOverflow questions other people asked on StackOverflow other websites about C programming
    8. If you have a question about the course policy, who can answer it?
      Your instructor Another faculty member Another student Your dog
  4. Write a program that prints rectangles (in text) on the screen. The outline of the rectangles should be in * characters and the inside should be empty (i.e., filled with spaces).

    Your rectangle will have a certain height and width, as well as an offset which is a number of spaces to the left of the left side of your rectangle.

    Here are some examples of how your program should work:

    roche@ubuntu$ ./rect
    Height: 5
    Width: 8
    Offset: 3
       ********
       *      *
       *      *
       *      *
       ********
    roche@ubuntu$ ./rect
    Height: 3
    Width: 10
    Offset: 7
           **********
           *        *
           **********

    In writing your program, use the idea of stepwise refinement that we talked about in class. You may assume that the height and width will always be at least 2.

    Submit the file rect.c using 204sub command. In addition, use the codeprint command to make a PDF of your file, print it out on paper, and include that with what you turn in (stapled together).