:lol: What the procedure/function for working out the biggest/smallest result?
This is the program i am trying to do..and i am supposed to show the user the highest student mark, and the lowest student mark, but i don't know how to.........argh!"

Please Help!:eek:

program ftn_marks;
{$APPTYPE CONSOLE}
uses
  SysUtils;
const students= 15;
type
Tmarks = array[1..students] of integer;
{PRE: true
POST: Introduce all The Marks}
Procedure initialise(var ftn:Tmarks);
  var
    i,mark:integer;
  begin
    writeln('Introduce The Marks For The 20 Students');
      for i:=1 to students do
        begin
        write('student ',i);readln(mark);
        ftn[i]:=mark;
        end;
{PRE:true
POST:show results}
procedure Show_results(ftn:Tmarks);
  var
    i:=integer;
  begin
    writeln('The Students Marks Are==> ',);
    for i:=1 to students do
      writeln('student ',i, 'Mark==> ',ftn[i]);
end;
{PRE: true
POST: return Average}
function Average(ftn:Tmarks):real;
  var
    sum,i:integer
  begin
    sum;=0;
    for i:=1 to students do
      sum:=sum+ftn[i];
    result:=sum/students;
end;
{PRE: true
POST: initialise all the marks to 0}
procedure initialise_marks(var ftn:Tmarks);
  var i:integer;
  begin
    for i:=1 to students do
 begin
            ftn[i]:=0;
        end;
end {initialise_module};
{PRE: true}
{Post: Introduce the marks}
procedure read_marks(var ftn:Tmarks);
begin
end;
{PRE: true
POST: show all the marks}
procedure write_marks(ftn:Tmarks);
begin
end;
{PRE: ftn is not empty
POST: average mark for the mdoule}
function average_mark(ftn:Tmarks):real;
  var av:real;
      std:integer;
begin
    av:=0;
    for std:=1 to students do
      begin
        av:=av+ftn[std];
      end;
    result:=av/students;
end;
{PRE: ftn is not empty
POST: maximum mark}
function max_mark(ftn:Tmarks):integer;
begin
end;
{PRE: ftn is not empty
POST: minimum mark}
function min_mark(ftn:Tmarks):integer;
begin
end;
 
{PRE: true
POST: menu with all the functionalities}
procedure menu(var ftn:Tmarks; c:char);
begin
  case c of
   'r', 'R': read_marks(ftn);
   'w','W': write_marks(ftn);
   'a','A': average_mark(ftn);
   'M': max_mark(ftn);
   'm': min_mark(ftn)
  else
    writeln('error this option has not been recognised');
   end;
end; {menu}
procedure prompts;
Begin
    writeln('Enter r to introduce all the marks');
    writeln('Enter w to show all the marks');
    writeln('Enter a to calculate  average mark');
    writeln('Enter M to calculate maximum mark');
    writeln('Enter m to calculate minumum mark');
    writeln('Enter q to quit');
end;
var FTN:Tmarks; choice:char;
begin
 initialise_marks(FTN);
 writeln('Welcome to Course statistics');
 writeln ('You have the following options');
 prompts;  readln(choice);
 while (choice <> 'q') and (choice<> 'Q') do
    begin
 menu(FTN,choice);
     prompts;
 readln(choice);
   end;
writeln('Bye...');
readln;
end

;) :idea:

You would have to a do a sort of some kind to get the lowest and highest values in the array, then go back and assign them to the original student number. Your array would then go from a single dimension to a 2 dimension and your sort would be on the score...Not to difficult, but a good coding challenge.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.