Sunday, October 14, 2018

Pascal program to find max min

Draw a Flow chart and Write a Pascal program to input list of positive numbers; terminate the input by entering a negative number and Print the Maximum and the Minimum number of the list of numbers.

Find Maximum and Minimum numbers from list of positive numbers


program maxmin;

var
num,max,min:integer;

begin
  {enter first number}
  write('Enter a number?');
  readln(num);
  {assume first num is the max}
  max:=num;
  {assume first num is the min}
  min:=num;
  {loop to get 0 or positive numbers }
  while num >=0 do
       begin
       {new num is greater then max is new num}
       if num > max then
        max:=num
      else
           {new num is minimum then min is new num}
        if num < min then
        min:=num;
       {enter new number}
       write('Enter a number?');
       readln(num);
    {repetition end}
    end;
 {Check for first num negative}

    if (max > 0) then
    begin
        writeln('Maximm number is',max);
        writeln('Miimum Number is',min);
        writeln('Press return key to exit...');
    end
    else
        Writeln('No Number to Display');
readln;
end.


Click below link to Get Pascal Practical Explanation to count vowels in a given string



No comments:

Post a Comment