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

Username:   Password: 
 RegisterRegister   
 Why does this not work
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Luffy123




PostPosted: Wed Jun 06, 2012 8:06 am   Post subject: Why does this not work

I got this from the turing documentation.

code:

var howMany : int
get howMany
var height : array 1 .. howMany of real

function total (a : array 1 .. * of real) : real
    var sum : real := 0
    for i : 1 .. upper (a)
        sum := sum + a (i)
    end for
    result sum
end total

put "Sum of the heights is ", total (height)



I dont' understand why it doesn't work. The error I get is

sum := sum + a (i)

Variable has no value in this line
Sponsor
Sponsor
Sponsor
sponsor
Amarylis




PostPosted: Wed Jun 06, 2012 8:21 am   Post subject: RE:Why does this not work

Look carefully at the code: Which one of the two in that line do you know already has a value, sum, or a (i)?
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  [ 2 Posts ]
Jump to:   


Style:  
Search: