Sabtu, 21 Agustus 2010

Contoh-Contoh Program Delphi I

Program mencari luas dan keliling segi empat

Program Latihan1;

uses
Forms;

{$APPTYPE CONSOLE}
var P,L,K,LS: integer ;

begin
write ('Panjang : ');readln(P);
write ('Lebar : ');readln(L);
K:=(P*2)+(L*2);
LS:=P*L;
writeln('Keliling: ',K);
writeln('Luas : ',LS);
readln;
end.



Program mencari luas dan keliling lingkaran

program Latihan2;

uses
Forms;

{$APPTYPE CONSOLE}
var R,LS,K:Real;

begin
write ('Jari-jari: ');readln(R);
writeln('Lingkaran');
writeln('-----------------');
LS:=22/7*R*R;
K:=2*22/7*R;
writeln('Jari-jari: ',R:5:2);
writeln('Luas : ',LS:5:2);
writeln('Keliling : ',K:5:2);
readln;
end.




Program menghitung konversi suhu

program Latihan3;

uses
Forms;

{$APPTYPE CONSOLE}
var C,F,R,K:Real;

begin
writeln('Konversi Suhu');
writeln('------------------');
write ('Celcius : ');readln(C);
F:=9/5*C+32;
R:=4/5*C;
K:=C+273;
writeln('Fahrenheit: ',F:5:2);
writeln('Reamur : ',R:5:2);
writeln('Kelvin : ',K:5:2);
readln;
end.

Tidak ada komentar:

Posting Komentar