The Icon Programming Language

An Iteration Example Program


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

Description

This program demonstrates the every function of the Icon programming language by displaying the sum of the numbers from 1 to 100.

Source Code

  procedure main()
      local n, sum             # Declare two local variables

      sum  :=  0;              # Set the sum to zero

      every  n := 1 to 100  do # For n equal to 1, 2, 3, 4, 5 ...
        sum  :=  sum + n;      # ...add n to the sum

      write ( "The sum of all numbers from 1 to 100 is ", sum );
    end
Click
here to download a zip file containing the source code.

Sample Run

The sum of all numbers from 1 to 100 is 5050

Click here to download a zip file containing the executable for MS-DOS.


Program Notes

This program was implemented using Version 9.1 of Icon for MS-DOS.
[Back] [Home]

Last modified: 11:30 AM on 11/25/1996