dengan Pascal
Berikut Source Code Program :
Program extreme_search;
Uses crt;
Type
Arrint = array [1..100] of integer;
Var
maks, minm, jlh, i : integer;
tabint : arrint;
Function maksimum(tabint : arrint; n : integer) : integer;
Var
i,max : integer;
Begin
For i:=1 to n do
If max < tabint[i] then
Max:= tabint[i];
Maksimum:=max;
End;
Function minimum(tabint : arrint; n : integer) : integer;
Var
i,min : integer;
Begin
For i:=1 to n do
If min > tabint[i] then
Min:= tabint[i];
Minimum:=min;
End;
Begin
Clrscr;
Writeln('Program Extreme Search');
Writeln('======================');
writeln;
Write('Jumlah Data = '); readln(jlh);
Writeln;
Write('Inputkan Data = ');
For i:= 1 to jlh do
Begin
Gotoxy(13+(i*4),6); readln(tabint[i]);
End;
Writeln;
Maks:=maksimum(tabint, jlh);
Minm:=minimum(tabint, jlh);
Writeln('Nilai Terbesar = ',maks);
Writeln('Nilai Terkecil = ',minm);
Readln;
End.
Dan berikut adalah output program diatas:
1. Tampilan saat program dijalankan
2. Tampilan saat jumlah data yang diinginkan diinput
3. Tampilan saat data diinputkan
4. Tampilan saat data telah ditemukan maksimum dan
minimumnya