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

Username:   Password: 
 RegisterRegister   
 False, but only on every other iteration...
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Matt_872000




PostPosted: Tue Jun 07, 2005 10:36 am   Post subject: False, but only on every other iteration...

How would I make it so that a boolean variable is false on every odd iteration of an infinite loop?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Jun 07, 2005 10:50 am   Post subject: (No subject)

if i is your counter then
boolean:= (i mod 2 = 0)
[Gandalf]




PostPosted: Tue Jun 07, 2005 3:49 pm   Post subject: (No subject)

Woah... How would that work? An explanation please.
Tony




PostPosted: Tue Jun 07, 2005 4:56 pm   Post subject: (No subject)

I'll just show you a sample
Turing:

for i : 1 .. 10
    put "iteration value: ", i, " -- boolean value: ", i mod 2 = 0
end for

The problem asks for boolean value to be false for odd numbers. Which translates into true for even numbers. Even numbers are defined as having a remainder of 0 when divided by 2.
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  [ 4 Posts ]
Jump to:   


Style:  
Search: