Kamis, 11 Februari 2010

Source Code Program Bagi Dua di Pascal

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 Akar:= ',c);
writeln('Jumlah Iterasinya:=',i);
readln;
End.

0 comments:

Posting Komentar

Twitter Delicious Facebook Digg Stumbleupon Favorites More

Enter your email address to subscribe:

Delivered by FeedBurner

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | SharePoint Demo