SI 204 Spring 2017 / HWs

This is the archived website of SI 204 from the Spring 2017 semester. Feel free to browse around; you may also find more recent offerings at my teaching page.

Homework 09: Nested loops

Name: _____________________________________________ Alpha: ___________________

Describe help received: ________________________________________________________

  • Due before class on Wednesday, February 1
  • This homework contains code to be submitted electronically. Put your code in a folder called hw09 and submit using the 204sub command.
  • This is an electronic homework and you do not need to print out anything to turn in during class.


  1. Required reading: Section 5 (Nested loops & Stepwise refinement) from the Unit 3 notes, Note: You do not need to go through the full example in section 5.4 (stepwise refinement from the inside out) if you will be in class.
  2. Write a program called counting.c that reads an integer \(n\) from the user, and then uses a nested loop to count from 1 up to 1, then from 1 up to 2, then from 1 up to 3, etc., and finally from 1 up to \(n\).

    Example of running your program:

    roche@ubuntu$ ./counting
    Enter n: 5
    1 2
    1 2 3
    1 2 3 4
    1 2 3 4 5

    Note: be careful not to print an extra space at the end of each line!