
-----------------------------------
dc116
Tue Dec 16, 2008 6:32 pm

My program won't run because of an error
-----------------------------------
Here's my program.


procedure minmax(list: array 1..* of int,
        var minimum, maximum : int, number : int)
    minimum := list(1)
    maximum := list(1)
    for i: 2..number
        if list (i) > maximum then
            maximum := list (i)
        elsif list (i) < minimum then
            minimum := list (i)
        end if
    end for
end minmax

%The "agespan" program
%Computes the difference between the largest and the smallest element in an array of ages
type ageRange : 1..120
put "Enter the number of ages"
var number :int
get number
var age: array 1 ..number of ageRange
%Read in array with number elements
put "Enter ", number, " ages"
for i: 1..number
    get age(i)
end for

var largest, smallest: ageRange
minmax(age,smallest,largest,number)
put "Age span in group is ", largest-smallest


When I run it, it says "argument is the wrong type" :? 
Can anyone help me fix the problem?

-----------------------------------
Tony
Tue Dec 16, 2008 6:48 pm

RE:My program won\'t run because of an error
-----------------------------------
minmax is expecting list: array 1..* of int
what is the type of age?

-----------------------------------
dc116
Tue Dec 16, 2008 7:46 pm

Re: RE:My program won\'t run because of an error
-----------------------------------
minmax is expecting list: array 1..* of int
what is the type of age?

Ohhhh thanks Tony, turned out all I had to do was take out this line:

type ageRange : 1..120


and replace all the ageRange with int so the variable age is declared as an integer.
