Revisi Program bagi dua di Pascal:
program bagi_dua;
uses crt;
const
e=0.00001;
var
i:integer;
a,b,c,fa,fb,fc:real;
begin
clrscr;
writeln('---------------------------------------------------');
writeln('| i | | a| | b | | c | | fa | | fb | | fc | | b-a |');
writeln('---------------------------------------------------');
writeln('Iput a'); Readln(a);
writeln('Input b'); Readln(b);
repeat
i:=i+1;
c:=(a+b)/2;
fa:=e*sqr(a)-5*sqr(a)*sqr(2);
fc:=e*sqr(c)-5*sqr(a)*sqr(2);
if fc=0 then
begin
a:=c;
b:=c;
end
else
if fa*fc<0 then
b:=c
else
a:=c;
until
abs(b-a)
writeln('Jumlah Iterasinya:=',i);
readln;
End.
Kamis, 11 Februari 2010
Source Code Program Bagi Dua di Pascal
Kamis, Februari 11, 2010
Galiarta
No comments
0 comments:
Posting Komentar