home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / PASCSRC.ZIP / AREAS.PAS < prev    next >
Pascal/Delphi Source File  |  1988-01-15  |  1KB  |  51 lines

  1.                                        (* Chapter 13 - Program 1 *)
  2. unit Areas;
  3. (*****************************************************************)
  4. (*                                                               *)
  5. (* This unit includes a collection of functions to calculate the *)
  6. (* areas of four different geometric shapes.                     *)
  7. (*                                                               *)
  8. (*****************************************************************)
  9.  
  10. interface
  11.    function Area_Of_Circle(Radius : real ) : real;
  12.    function Area_Of_Square(Length_Of_Side : real) : real;
  13.    function Area_Of_Rectangle(Length,Width : real) : real;
  14.    function Area_Of_Triangle(Base, Height : real) : real;
  15.  
  16. implementation
  17.  
  18. var My_Pi : real;
  19.  
  20. procedure Mult_Two_Numbers(Number1, Number2 : real;
  21.                            var Result : real);
  22. begin
  23.    Result := Number1 * Number2;
  24. end;
  25.  
  26. function Area_Of_Circle;
  27. var Rad_Squared : real;
  28. begin
  29.    Mult_Two_Numbers(Radius,Radius,Rad_Squared);
  30.    Area_Of_Circle := Rad_Squared * My_Pi;
  31. end;
  32.  
  33. function Area_Of_Square;
  34. begin
  35.    Area_Of_Square := Length_Of_Side * Length_Of_Side;
  36. end;
  37.  
  38. function Area_Of_Rectangle;
  39. begin
  40.    Area_Of_Rectangle := Length * Width;
  41. end;
  42.  
  43. function Area_Of_Triangle;
  44. begin
  45.    Area_Of_Triangle := Base * Height / 2.0;
  46. end;
  47.  
  48. begin                   (* This is the initialization code *)
  49.    My_Pi := 3.14159267;
  50. end.  (* of unit Areas *)
  51.