Compute The Mean Example Program

Click below to go directly to a specific section:
Description | Source Code | Program Notes


This program computes the mean (average) of the absolute value of an array. Block structures, a dynamic array, and iterative statements are featured in this program. The bold type print represent keywords.

Source Code

// the main program (this is a comment)

  integer N;
  Read Int(N);

    real array Data[1:N];
    real sum, avg;
    integer i;

    for i:=1 step 1 until N do
      begin real val;
        Read Real(val);
        Data[i]:=if val<0 then -val else val

    for i:=1 step 1 until N do
      sum:=sum + Data[i];
    Print Real(avg)

Program Notes

This program has NOT been tested due to the inability to locate the necessary compiler. It is posted here just to give you an example of what ALGOL source code looks like. Compare it to the other example listed to see the syntactic differences that exist in the language.
[Back] [Home]

Last modified: 08:52 PM on 11/21/1996