Post Reply 
Newbie Programming Confusion
08-22-2015, 08:10 PM
Post: #2
RE: Newbie Programming Confusion
(08-22-2015 06:44 PM)smp Wrote:  
Code:
EXPORT CalcPi()
BEGIN
// Calculate Pi by inscribed ploygons
// Original author:
// George W. Ball, Alfred University

  R:=10;  // Use a circle of radius 10
  N:=4;
  S:=R*√(2);

  PRINT();
  PRINT("Machine value for Pi = " +(4*ATAN(1)));
  PRINT("Machine value for Pi = " +PI);
  PRINT(" ");
  PRINT("Sides      Perimiter");
  FOR K FROM 1 TO 28 DO
    PRINT(N +"      " +((S*N)/(2*R)));

//    Y:= S*S/4;
//    H=√(R*R-Y);   <--- there is the ":" missing
//    X:=R-H;
//    S:=√(X*X+Y);  // does not work

//    S:=√((R-(√(R*R-(S*S/4))))*(R-(√(R*R-S*S/4)))+(S*S/4));  // works

    S:=√((R-√(R*R-(S/2)^2))^2+(S/2)^2);  // works

    N:=2*N;
  END;
END;

Please take a look (if you want) and if there is something obvious that I'm missing, please let me know.

TIA,
smp

H=√(R*R-Y); <--- there is the ":" missing
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Newbie Programming Confusion - smp - 08-22-2015, 06:44 PM
RE: Newbie Programming Confusion - Thomas_Sch - 08-22-2015 08:10 PM
RE: Newbie Programming Confusion - smp - 08-22-2015, 09:35 PM
RE: Newbie Programming Confusion - smp - 08-22-2015, 09:43 PM



User(s) browsing this thread: 1 Guest(s)