SI 204 Spring 2017 / HWs

Homework 08: For loop

Name: _____________________________________________ Alpha: ___________________

Describe help received: ________________________________________________________

  • Due before class on Monday, January 30
  • This homework contains code to be submitted electronically. Put your code in a folder called hw08 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: Sections 3 (Loop shortcuts) and 4 (Odds & ends) from the Unit 3 notes.
  2. Write a program called gaussfor.c that reads an integer \(n\) from the user, and then uses a for loop to add up the numbers from 1 to \(n\) and print out the sum.

    (Note: this is the same program that you wrote for homework 6, except using a for loop instead of a while loop.

    Example of running your program:

    roche@ubuntu$ ./gaussfor
    Enter n: 100
    The sum of numbers from 1 up to 100 is 5050