CS21 Spring 2005
Homework 3
Due Sunday, January 30, before 11:30 pm

This assignment should be done individually (no partners).

Answer the following Review Questions from the C book on your own, but do not turn them in. I will post answers on the CS21 web page next week.

Please complete the following 4 programs and turn them in. In addition, you can complete the extra credit problem for up to half a grade increase on this homework grade (go from a 3 to a 3.5 for example). After Tuesday's lecture you should be able to at least get a start on the first three problems.

Remember: if your program has an infinite loop (you run it and it never terminates) you can kill it by typing Ctrl-C in the window in which it is running.

  1. Programming Exercise 3.14: display largest value in list (page 96)
    Write a program that reads in some number of integers from the user until the user enters the value 0 as a sentinel. When the sentinel appears, your program should print the largest value in the list.

  2. Programming Exercise 4.5 (p.134)
    Write a program that prints out all numbers between 1 and 100 that are evenly divisible by 6 or by 7 but not by both.

  3. Programming Exercises 4.8: Fibonacci program (p.135)
    Write a program that computes and displays the first 15 Fibonacci numbers, see the exercise in the text for an explaination of the Fibonacci sequence and to see an example of how your program's output should be formatted.

  4. Programming Exercises 4.11: Pyramid of Stars (p.136). You may want to try problem 4.10 first, and then modify it to get your solution to 4.11. Also, remember that you copied over my stars.c program in class on Thursday. You can use this as a starting point for this problem.

Extra Credit (for half a grade more on this assignment)
For those of you who like an extra challenge, try the following problem (only try this after you have completed all the regular parts of this assignment).

Please use the cs21handin command to turn in your homework.