SELAMAT DATANG DI WWW.POKOKNYAENAK.BLOGSPOT.COM

Kami Hadir dengan Berbagai Info yang Pastinya Menarik....

Cari sesuatu? Di Mbah Google saja...ketikkan kata kunci di kotak di bawah ini

Custom Search

Thursday, March 10, 2011

Program Mencari Akar Dengan Metode Bisection

program MencariAkar;

uses wincrt;

Const E=0.1;

Label back, finish;

var X0, X1, X2, Y0, Y1, Y2, D, R, P :real;

Y : integer;

function F(X:real):real;

begin

f:=X*X*X-X-1;

end;

Procedure Judul;

begin

writeln('************ TABEL MENCARI AKAR DENGAN METODE BISECTION ************');

writeln('======================= ==================================================');

writeln(' X0 X1 Y0 Y1 P X2 Y2 D R ');

writeln('==========================================================================');

end;

begin

clrscr;

Y:=8;

write(' * Masukkan Nilai X0 = ');readln(X0);

write(' * Masukkan Nilai X1 = ');readln(X1);

writeln; Judul;

Back: Y0:=F(X0);

Y1:=F(X1);

D:=Y0*Y1;

if D>0 then

begin

gotoxy(27,Y+2);writeln('Tabel Tidak Ada');

gotoxy(20,Y+3);writeln('Iterasi Tidak Dapat Dilakukan');

goto finish;

end;

X2:=(X0+X1)/2;

Y2:=F(X2);

R:=Y0*Y2;

if R=0 then

begin

write(' Akar = ',X2:8:4);

goto Finish;

end;

if R>0 then

X0:=X2;

if R<0>

X1:=X2;

P:=Abs ((X0-X1)/X0);

if P>E then

begin

gotoxy(1,Y);write(' ',X0:1:2);

gotoxy(9,Y);write(' ',X1:1:2);

gotoxy(17,Y);write(' ',Y0:1:2);

gotoxy(25,Y);write(' ',Y1:1:2);

gotoxy(33,Y);write(' ',P:1:2);

gotoxy(41,Y);write(' ',X2:1:2);

gotoxy(51,Y);write(' ',Y2:1:2);

gotoxy(60,Y);write(' ',D:1:2);

gotoxy(68,Y);write(' ',R:1:2);

gotoxy(76,Y);write(' ');

Y:=Y+1;

goto Back;

end;

if P<=E then

begin

writeln;

writeln('========================================================================');

write(' Akar = ',X2:8:4);

end;

Finish: Readln;

end.



Daftar Menu

What is your Opinion about this blog?

Counter Strike

Powered By Blogger