# iterative program to sum elements of an array # store in a file such as "sum.sr" # compile by executing "sr sum.sr" # run by executing "a.out size" resource sum() var size: int; getarg(1,size) var a[1:size] : int # same as a[size] fa i := 1 to size -> a[i] := i af var total := 0 fa i := 1 to size -> total := total + a[i] # same as total +:= a[i] af write("the sum of 1 ...", size, "is", total) end