Homework 2 Csc309.

Due Monday April 10, 2006 by 11:59pm.

Problem 1

(25 Points)

From the Kalin text.

The expression C(n,r) denotes the number of r-element subsets on an n-element set. For example C(4,2) is 6 because there are six 2-element subsets of a 4-element set. The value of C(n,r) is given by the formula.

Write a program that computes C(n,r) using at least these component functions, which are invoked by main:

The function main prints the result

Work incrementally, that is after you write a function test it out. Make up some test cases and check for invalid inputs. Don't forget factorial grows rapidly so use reasonable numbers. Later we will look at another way to deal with large numbers.

Problem 2

(25 Points)

For this problem you will add two functions to statistics.cpp. You must use iterators in each of the functions when interacting with the vector.