Sunday, February 14, 2016

Highest and Lowest Number in Pascal

This simple program will check which of the ten numbers in an array is the highest and the lowest using Pascal as our programming language. I am using Turbo Pascal 5.0 as my Pascal compiler in this sample program.

If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

program high_low;

uses crt;

var
  numbers:array[1..10] of integer;
  high:integer;
  low:integer;
  x:integer;


procedure quit;
begin
  writeln;
  writeln;
  writeln('Press <Enter> to Quit');
  readln;
end;

begin
  clrscr;
  numbers[1]:=2;
  numbers[2]:=3;
  numbers[3]:=-34;
  numbers[4]:=23;
  numbers[5]:=6;
  numbers[6]:=-345;
  numbers[7]:=7;
  numbers[8]:=9;
  numbers[9]:=10;
  numbers[10]:=123;

  writeln('Highest and Lowest Number Checker in Pascal');
  writeln;


  high := numbers[1];
  low := numbers[1];

  for x := 1 to 10 do
  begin
    if numbers[x] > high then
       high := numbers[x];

    if numbers[x] < low then
       low := numbers[x];
  end;

  writeln('The Highest Number: ', high);
  writeln('The Lowest Number: ', low);
  quit;
  End.



No comments:

Post a Comment