Contoh Program Function
Program Menentukan Bilangan Terkecil
Program Fungsi;
uses wincrt;
function kecil (A,B : integer): integer;
begin
if A
kecil := A
else
kecil := B;
end;
var
A,B: integer;
begin
clrscr;
write('Nilai Bilangan 1 = '); readln(A);
write('Nilai Bilangan 2 = '); readln(B);
writeln;
write('Bilangan Terkecil = ', kecil (A,B):5);
readln;
end.
uses wincrt;
function kecil (A,B : integer): integer;
begin
if A
kecil := A
else
kecil := B;
end;
var
A,B: integer;
begin
clrscr;
write('Nilai Bilangan 1 = '); readln(A);
write('Nilai Bilangan 2 = '); readln(B);
writeln;
write('Bilangan Terkecil = ', kecil (A,B):5);
readln;
end.
HASIL PROGRAM
Komentar
Posting Komentar