*/
Know a good article or link that we're missing? Submit it!
*/

View \AREAS.PAS

Getting Started with the Pascal tutorial, source

Submitted By: WEBMASTER
Rating: (Not rated) (Rate It)


(* Chapter 13 - Program 1 *)
unit Areas;
(*****************************************************************)
(*                                                               *)
(* This unit includes a collection of functions to calculate the *)
(* areas of four different geometric shapes.                     *)
(*                                                               *)
(*****************************************************************)

interface
   function Area_Of_Circle(Radius : real ) : real;
   function Area_Of_Square(Length_Of_Side : real) : real;
   function Area_Of_Rectangle(Length,Width : real) : real;
   function Area_Of_Triangle(Base, Height : real) : real;

implementation

var My_Pi : real;

procedure Mult_Two_Numbers(Number1, Number2 : real;
                           var Result : real);
begin
   Result := Number1 * Number2;
end;

function Area_Of_Circle;
var Rad_Squared : real;
begin
   Mult_Two_Numbers(Radius,Radius,Rad_Squared);
   Area_Of_Circle := Rad_Squared * My_Pi;
end;

function Area_Of_Square;
begin
   Area_Of_Square := Length_Of_Side * Length_Of_Side;
end;

function Area_Of_Rectangle;
begin
   Area_Of_Rectangle := Length * Width;
end;

function Area_Of_Triangle;
begin
   Area_Of_Triangle := Base * Height / 2.0;
end;

begin                   (* This is the initialization code *)
   My_Pi := 3.14159267;
end(* of unit Areas *)

corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.