Computer Science Canada

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

Author:  Anastasia [ 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

Author:  tyuo9980 [ 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

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

Thank you!
Very Happy


: