Find Minimum and Maximum Number using Array in Pascal

This is the source code to search the minimum and maximum of 5 numbers.

LINK VIDEO HERE

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.

pascal10.png


If you love solving puzzle and sudoku or interested to discuss about anything you can visit my social:

Social Links


Leave a comment