Computer Science Canada Operands of comparison |
Author: | Angel [ Sun Jan 04, 2004 6:52 pm ] | ||||
Post subject: | Operands of comparison | ||||
I'm having a problem with a program I'm writing, and there's something wrong with the operands of comparison:
This is an example code that I am using. When I try to run the program, it highlights the following:
It says that there's a syntax error at '<'. Help?! ![]() |
Author: | Tony [ Sun Jan 04, 2004 7:18 pm ] |
Post subject: | |
shouldn't that be <= ![]() |
Author: | Angel [ Sun Jan 04, 2004 7:24 pm ] |
Post subject: | |
Yeah I've tried that too but then it highlights the number and says that Operands of boolean operators must be Boolean. And I have no clue what it means. Ok do you think that it might have anything to do with the fact that I declared questions1 as an array of int? ![]() |
Author: | Tony [ Sun Jan 04, 2004 7:30 pm ] |
Post subject: | |
exit when might be buggy... try to spit it into two exit when >= 1 exit when <= 3 |
Author: | Angel [ Sun Jan 04, 2004 7:42 pm ] |
Post subject: | |
I get the same crap... I really don't wanna do it the long way and type out the stuff using or!!! ![]() |
Author: | DanShadow [ Sun Jan 04, 2004 7:54 pm ] | ||||
Post subject: | |||||
Im assuming your "questions1" variable is an array right? What kind of variable is it? (int/string/char) Oh, and wh en trying to get an answer from a user..try using a loop, it works for me.
hmm...I think I found your error! Your exit is saying: I will exit when questions(3) is greater or equal to 1, or when questions1(3) is less or equal to 3. Hmm....this doesnt make sense.....how can I exit using an "or" statement, which both sides of the or statement lead to the same thing???? In other words, you cant have it so its checking if the answer is greater or equal to 1, or less or equal to three, it must be and AND s tatement.
Hope this helps! |
Author: | Angel [ Sun Jan 04, 2004 8:02 pm ] | ||
Post subject: | |||
You know, when I looked at it again I thought the same thing... but changed the or statement to an and didn't help. And it is an int array. I do have the "get answer" in a loop:
So I have no idea what's wrong! ![]() |
Author: | Ashkan [ Sun Jan 04, 2004 11:52 pm ] | ||
Post subject: | |||
|
Author: | Ashkan [ Sun Jan 04, 2004 11:58 pm ] | ||
Post subject: | |||
simply you can use this one two basiclly same but since you want to know your mistake its like puting <= not >= and i made your code simpler
|
Author: | Angel [ Mon Jan 05, 2004 10:47 pm ] |
Post subject: | |
Thanks guys! |