Thursday, April 20, 2017

Maximum Number in Turbo Pascal

In this article I would like to share with you a sample program that will ask the user to give two numbers and then our program using functions in Pascal will check and determine which of the two number is the biggest in terms of numerical value. I wrote this code using Turbo Pascal 6.0 for DOS. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.






Sample Program Output


Program Listing


Program maximum_two_numbers;

Uses Crt;

Var val_1,val_2, return_value : Integer;


function maximum_checking(a, b: integer): integer;
var
   
   result: integer;

begin
   if ( a> b) then
      result := a
   
   else
      result := b;
     maximum_checking := result;
end;


Begin
  Clrscr;
  val_1 := 0; val_2 := 0;
  writeln;
  Writeln;
  Write('Maximum Number in Turbo Pascal');
  writeln;
  Writeln;
  Write('Enter First Value : ');
  Readln(val_1);
  Write('Enter Second Value : ');
  Readln(val_2);

  return_value := maximum_checking(val_1,val_2);

  writeln;
  writeln('The maximum value between ' ,val_1, ' and ', val_2, ' is ' ,return_value,'.');
  writeln;
  Writeln;
  Write('End of Program');
  Writeln;
  Readln;
End.




No comments:

Post a Comment