// Summing a series /* -------------Problem------------ Based on page 215 of Koffman & Friedman -------------Analysis----------- DATA REQUIREMENTS Constants None Inputs n - the number of numbers to be summed (int) Outputs sum - the sum 1+2+3+..n FORMULAE --------------Design------------- INITIAL ALGORITHM 1. Get n 2. compute sum 3. display sum REFINEMENTS 2. compute the sum IN: int n -- number of numbers returns: int sum -- Sigma [i in 1..n] (i) Additional variable int i as loop control and 2.1 set sum to 2.2 For i = 1,2,3,..., 2.2.1 add i to sum ------------Implementation--------- */ #include #include int main( ) { int n; //input: number of numbers int sum;//output: sum of numbers // Uses int compute_sum(int); //1. Get n cout<<"Input a whole number greater than 0: "; cin >>n; //2. compute sum sum=compute_sum(n); //3. display sum cout<<"Sum 1+2+..+"<