program extreme_search;
uses crt;
type
arrint = array [1..100] of integer;
var
maks, minm, jmlh, i : integer;
tabint : arrint;
function terbesar(tabint : arrint; n : integer) : integer;
var
i,max : integer;
begin
for i:=1 to n do
if max < tabint[i] then
max:= tabint[i];
terbesar:=max;
end;
function terkecil(tabint : arrint; n : integer) : integer;
var
i,min : integer;
begin
for i:=1 to n do
if min > tabint[i] then
min:= tabint[i];
terkecil:=min;
end;
begin
clrscr;
writeln(' Extreme Search ');
writeln('===================================');
writeln('Mencari Nilai Terbesar dan Terkecil');
writeln;
write('Jumlah Data = '); readln(jmlh);
writeln;
write('Inputkan Data = ');
for i:= 1 to jmlh do
begin
Gotoxy(13+(i*4),7); readln(tabint[i]);
end;
writeln;
maks:=terbesar(tabint, jmlh);
minm:=terkecil(tabint, jmlh);
writeln('Nilai Terbesar = ',maks);
writeln;
writeln('Nilai Terkecil = ',minm);
readln;
end.
B. Screenshot Program
Gambar 1. Tampilan awal program
Gambar 2. Tampilan input jumlah data
Gambar 3. Tampilan input data
Gambar
4. Tampilan output nilai terbesar dan nilai terkecil
Tidak ada komentar:
Posting Komentar