Langsung ke konten utama

Find Minimum and Maximum Number using Array in Pascal

 


If you want to make a program like the image above, this is the source code:

program aray2;
uses crt;
type
nilai=array [1..5] of integer;
var l:byte; max,min: integer;
n:nilai;
begin
    clrscr;
     writeln(‘========================’);
     for l:=1 to 5 do
     begin
         write(‘ Value number-‘,l,’: ‘);
         readln(n[l]);
     end;
     min:=n[1];
     max:=n[1];

    for l:=1 to 5 do
     begin
         if (n[l]<min) then
         begin
             min:=n[l];
          end;
         if (n[l]>max) then
         begin
             max:=n[l];
         end;
     end;
     writeln(‘========================’);
     writeln(‘ Maximum Value : ‘,max);
     writeln(‘ Minimum Value : ‘,min);
     writeln(‘========================’);
     readln;
end.