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

Username:   Password: 
 RegisterRegister   
 What does "operands of boolean operators must be boolean" mean?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Anastasia




PostPosted: Fri May 13, 2011 7:52 pm   Post subject: What does "operands of boolean operators must be boolean" mean?

What does this mean "operands of boolean operators must be boolean"?




Turing:


var action: string

loop
put""
get action
if action = "read the note" or "read note" or "read it" then
put "Hi there! (Rules of the game)"
else
put "Read the note!"
end if
end loop



Please help

Thanks in adverse! Smile
Sponsor
Sponsor
Sponsor
sponsor
tyuo9980




PostPosted: Fri May 13, 2011 8:31 pm   Post subject: Re: What does "operands of boolean operators must be boolean" mean?

this is a very common beginner mistake. when you're using 'or' or 'and' you have to restate what you're comparing

eg.

if x = 5 or y - 5 then

you might think that x could be either one but the program thinks individually:
if x = 5 or '??' y - 5 then

you will have to restate the comparison variable and operator.

the correct statement would be:
if x = 5 or x = y - 5 then


ps. use the indent button. its one click and makes the code all neat and tidy
Anastasia




PostPosted: Mon May 16, 2011 8:12 am   Post subject: Re: What does "operands of boolean operators must be boolean" mean?

Thank you!
Very Happy
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: