Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 My program won't run because of an error
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
dc116




PostPosted: Tue Dec 16, 2008 6:32 pm   Post subject: My program won't run because of an error

Here's my program.

Turing:

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" Confused
Can anyone help me fix the problem?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Dec 16, 2008 6:48 pm   Post subject: RE:My program won\'t run because of an error

minmax is expecting list: array 1..* of int
what is the type of age?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
dc116




PostPosted: Tue Dec 16, 2008 7:46 pm   Post subject: Re: RE:My program won\'t run because of an error

Tony @ Tue Dec 16, 2008 6:48 pm wrote:
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:
Turing:

type ageRange : 1..120


and replace all the ageRange with int so the variable age is declared as an integer.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: