Next / Previous / Index / ITC Help System / Publications / Site map / NM Tech homepage

Doing simple arithmetic in Icon

Tech Computer Center logo

Here is a simple Icon program that finds the sum of the numbers from one to five:

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

      sum  :=  0;              # Set the sum to zero

      every  n := 1 to 5  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 5 is ", sum );
Several new features are introduced in this program:
Next: How expressions work in Icon
See also: A tutorial for the Icon programming language
Previous: Compiling and running an Icon program
Site map
Index: Keyword index to help pages
Help: New Mexico Tech Information Technology and Communications: Help System
ITC Publications
To report a problem: File a ticket
Send mail to the User consultant on duty or call them at 575-835-5437
Home: About New Mexico Tech

John Shipman,
Last updated: 1996/01/06 21:12:57 UT
QR two-dimensional bar code