Problem Set Number 7
Computer Science 111

Due by 5 PM, Friday March 31, 2000

All the questions this week ask for programs in C. Perfection will not be expected, but please try to write really good C. (Remember that the language the text calls C++ is for our purposes just the same as C.)

1. Write a C program that will compute the sum of all the non-negative integers in a 64-element integer array called A (which may contain negative integers). Use a while loop to go through the array. Put the answer in an integer variable named answer.

2. Now solve the same problem as question 1, but use a for loop instead of a while. Here is that cheat-sheet on for loops.

3. Write a program in C to find the biggest and smallest integers in a 100-element positive integer array named Ralph, and then compute the remainder of the biggest divided by the smallest. The C operator % is just what you need: m % n is the remainder of m divided by n. First, do this by using two different loops, one for the biggest and one for the smallest. Use either for or while loops. Put the answer in a variable named gretchen.

4. Now solve the same problem as question 3, but use just one loop.

Extra credit: Visit and experiment with some Game of Life patterns. Try different speeds and zoom factors. From the Open menu-button you can select different pre-cooked starting patterns, some of which have amazing behavior. Write and turn in a short paragraph saying why one of these patterns particularly intrigued you.