Showing posts with label highest and lowest number in pascal. Show all posts
Showing posts with label highest and lowest number in pascal. Show all posts

Saturday, February 27, 2016

Find the Highest and Lowest Number in Pascal Version 2

This simple program will ask the user to give five numbers and then our program will check and determine which of the five number is the highest and lowest number. I used Pascal programming language in writing this program, my compiler is Turbo Pascal 5.0 for DOS. This is the version two of my program in Pascal.

I hope you will find my work useful in learning programming in Pascal.

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 Highest_Lowest_Number;
Uses Crt;

Type
   Number_Array = Array[1..5] of Integer;

Var N : Number_Array;
    I, Highest, Lowest : Integer;

Begin
  Clrscr;

  I :=0;
  Highest := 0;
  Lowest :=0;

  Writeln('Find the Highest and Lowest Number');
  Writeln;

   For I := 1 to 5 Do
   Begin
    Write('Please Enter Item No. ',I,':');
    Readln(N[I]);
   End;

   For I := 1 to 5 Do
   Begin
     If (Highest<N[I]) Then
        Begin
          Highest := N[I];
        End;

      If (Lowest>N[I]) Then
        Begin
          Lowest := N[I];
        End;
    End;

   Writeln;
   Write('List of Numbers');
   Writeln;
   For I := 1 to 5 Do
   Begin
     Write(' ',N[I],' ');

   End;

   Writeln;
   Writeln;
   Write('Display Result');
   Writeln; Writeln;
   Writeln('The Highest Number is ',Highest,'.');
   Writeln('The Lowest Number is ',Lowest,'.');
   Writeln;
   Write('End of the Program');
   Readln;
End.

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.