Minggu, 30 Oktober 2016

Program Delphi Untuk Mencetak Deret "1 + 1/2 + 1/4 + ..."

procedure TDeret3.Button15Click(Sender: TObject);
var
  i,n:integer;
  j,a,b,c,d,k:real;
begin
  n:=strtoint(edit11.Text);
  listbox5.Items.add('1');
  j:=0;
  for i:= 1 to n-1 do
  begin
  a:=1;
  b:= 2*i;
  c:=a/b;
  listbox5.Items.add(floattostr(c));
  j:= j+c;
  end;
  edit12.Text:=floattostr(j+1);

end;

procedure TDeret3.Button16Click(Sender: TObject);
begin
edit11.Text:=' ';
listbox5.items.Clear;
edit12.Text:=' ';

end;

procedure TDeret3.Button17Click(Sender: TObject);
begin
Deret.Show;
Deret3.Hide;
end;

0 komentar:

Posting Komentar