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

Username:   Password: 
 RegisterRegister   
 yes or no
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
blankout




PostPosted: Wed Apr 01, 2009 4:48 pm   Post subject: yes or no

is it possible to use an or statement for something like a yes or no answer like

Turing:

if answer="yes" or "no"
then


is this possible or am i just being stupid?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Wed Apr 01, 2009 5:06 pm   Post subject: RE:yes or no

code:

if boolean_expression or boolean_expression then
   ...
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Insectoid




PostPosted: Wed Apr 01, 2009 5:14 pm   Post subject: RE:yes or no

Tony, I think he means 'if A = b or C'

You have to type 'A' twice.

So, it would look like so;
code:

if answer = "yes" or answer = "no" then
    %whatever
end if

However, it seems quite illogical to have yes or no in the same one I would split it out. 'elsif' is your friend here.
code:

if answer = "yes" then
    %whatever
elsif answer = "no" then
    %whatever else
end if


There is also the 'else' command. Basically, if it isn't any of those things, do this.
code:

if answer = "yes" then
    %whatever
elsif answer = "no" then
    %whatever else
else
    put "this happens if answer doesn't equal yes or no"
end if
Tony




PostPosted: Wed Apr 01, 2009 5:18 pm   Post subject: RE:yes or no

the hint was that "no" is not a boolean expression.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Insectoid




PostPosted: Wed Apr 01, 2009 8:15 pm   Post subject: RE:yes or no

perhaps he doesn't know even what a boolean expression is, Tony. You have to remember that these kids no almost nothing about programming or even things as obscurely related to it as boolean expressions.
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  [ 5 Posts ]
Jump to:   


Style:  
Search: