{                                  Matt Michie                             }
{                                  Period 4 - Pascal                       }
{                                  Due Date: 4/12/94                       }
{                                  Filename: ex23ch5.pas                   }
{ Program description:  This program adds all the positive integers up to  }
{ and including that number using a recusive procedure.                    }
{                                                                          }
{                                                                          }
{!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
{ Grading Criteria:                                                        }
{                                                                          }
{                                          Header (5pts) ________________  }
{                                                                          }
{                             Program Description (5pts) ________________  }
{                                                                          }
{                                    Presentation (5pts) ________________  }
{                                                                          }
{                                 Run of Program (5pts)  ________________  }
{                                                                          }
{                                            Final Grade ________________  }
{                                                                          }
{===========================Main Program===================================}
program ex23ch5 (input,output);
uses crt;
var
  answer:integer;
{----------------------------------------------------------------------------}
procedure SumUp (N:integer;
                 var total:integer);
{Pre: N is assumed to be a positive integer although no checking is done ;) }
{Post: Total is modified to be the sum of all integers up to and including  }
{      the number entered using recursion                                   }
begin {SumUp}
   if n > 0
     then
       begin {if then}
         SumUp (N - 1, total);
         total := total + N;
       end;  {if then}
end;  {SumUp}
{============================================================================}
begin {main}
  clrscr;
  SumUp (10, answer);
  writeLn (answer);
  readLn;
end.  {main}
