View Single Post
  #2 (permalink)  
Old 06-15-2007, 04:44 AM
DR.Chemical
Posts: n/a
Try this:

Program Averages;
Var
Counter: Integer;
Marks: real;
Infile: Text;
Total: Real;
Average: Real;

Begin
Counter:= 0;
Assign(Infile, 'Marks.txt');
Reset(Infile);
while not Eof(InFile) do
begin
ReadLn(InFile, Marks);
Counter := Counter + 1;
Total := Total + Marks;
end;
Average := Total/Counter;
WriteLn('The average is: ' ,Average:2:2);
Close (Infile);
End.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!