Description |
The Pi function returns a floating point value giving a useful approximation of the value of Pi.
The circumference of a circle Pi * Diameter.
|
|
Related commands |
Cos |
|
The Cosine of a number |
Extended |
|
The floating point type with the highest capacity and precision |
Sin |
|
The Sine of a number |
Tan |
|
The Tangent of a number |
|
|
|
Example code : Get the area and circumference of a circle |
// Full Unit code. // ----------------------------------------------------------- // You must store this code in a unit called Unit1 with a form // called Form1 that has an OnCreate event called FormCreate. unit Unit1; interface uses // The System unit does not need to be defined SysUtils, Forms, Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} // Include form definitions procedure TForm1.FormCreate(Sender: TObject); var
myPi : Extended;
diam : Integer;
begin
diam := 10;
// Show circumference and the area of a circle // with diameter - 10 cm
ShowMessage(' Diameter = '+IntToStr(diam));
ShowMessage('Circumference = '+FloatToStr(Pi*diam));
ShowMessage(' Area = '+FloatToStr(Pi*(diam/2)*(diam/2)));
end; end.
|
Hide full unit code |
Diameter = 10
Circumference = 31.4159265358979
Area = 78.5398163397448
|
|