Displays the program for calculations rad = 1 -1/3 +1/5 -1/7
Delphi & Pascal (česká wiki)
Category: Homework in Pascal
Program: Radian.pas
File exe: Radian.exe
flow: Radian.gif
Program: Radian.pas
File exe: Radian.exe
flow: Radian.gif
Displays the program for calculations rad = 1 -1/3 +1/5 -1/7 ... with precision EPS.
{ RADIAN.PAS Copyright (c) TrSek alias Zdeno Sekerak } { Vypracujte program pre vypocet hodnoty radu: } { rad = 1 -1/3 +1/5 -1/7 ... so zadanou presnostou EPS } { } { Datum:04.02.2004 http://www.trsek.com } program rad_cisel; uses crt; var rad:real; eps:real; posl:real; rad1:real; krok:word; sign:real; begin ClrScr; Write('Zadaj presnost EPS s akou chces rad vypocitat:'); ReadLn( eps ); { pociatocne hodnoty } krok := 1; sign := 1; rad1 := 1; repeat posl := rad1; krok := krok + 2; sign := (-1) * sign; rad1 := sign/krok; rad := rad + rad1; until( abs(posl + rad1) < eps ); WriteLn('Hodnota radu je ', rad:8:3); ReadLn; end.