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

Username:   Password: 
 RegisterRegister   
 If Statements
Index -> General Discussion
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Aange10




PostPosted: Sat Dec 31, 2011 3:54 pm   Post subject: If Statements

I have a question about if statements:

code:

if ( i = 10 and e = 4 and r = 6 then) {
    do stuff
}


If i = 8, will it ever check for e or r?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sat Dec 31, 2011 4:39 pm   Post subject: RE:If Statements

Most languages will check the second argument only if the first is not enough to determine the outcome of the expression.

http://en.wikipedia.org/wiki/Short-circuit_evaluation

You can check for this yourself, by having the second argument of a boolean expression to perform some observable side-effect.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> General Discussion
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: