Koleksi program pascal


PROGRAM PASCAL SEDERHANA

KELIPATAN 5

uses crt;

var i:integer;

begin

clrscr;

for i:= 5 to 60 do

begin

if i mod 5=0 then write (i:20);

end;

readln;

end.

PENGGUNAAN IF

Uses Crt;

Var UMUR: Byte    ;

Begin

Clrscr;

Write(‘Inputkan Umur :’); Readln(UMUR);

If UMUR in [0..5] then writeln(‘BALITA’)

Else if UMUR in [6..16] then writeln (‘REMAJA’)

Else if UMUR in [17..99] then writeln(‘DEWASA’);

Readln;

End.

DETEKSI TOMBOL

Uses Crt;

Var TEKAN:Char;

Begin

Clrscr;

Write(‘Tekan Sembarang tombol..!’);

TEKAN:=Readkey;

Writeln;

Case TEKAN of

‘A’..’Z’,’a’..’z’ :Writeln(‘ Anda menekan tombol huruf’);

‘1’..’9′: Writeln(‘Anda menekan tombol angka’);

‘+’,’-‘,’*’,’/’:Writeln(‘Anda menekan tombol operator aritmatika’);

Else

Writeln(‘Anda menekan Special Char’);

End;

Readln;

End.

MENGHITUNG LUAS

program luaskamar;

uses crt;

var

panjang,lebar,tinggi:integer;

luas:real;

begin

clrscr;

write (‘masukkan panjangnya:’);readln (panjang);

write (‘masukkan lebarnya:’);readln (lebar);

write (‘masukkan tingginya:’);readln (tinggi);luas := panjang*lebar*tinggi;

writeln (‘luas kamar budi adalah =’,luas:8:2);

readln;end.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google

You are commenting using your Google account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s