Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

source file compilation

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry, i am talking about generally.
like for example, what will happen in this case:




will if(p1isright||p2isright||p3isright) command gets executed if atleast one of p1isright, p2isright, p3isright is false???

thanks
 
Marshal
Posts: 28123
94
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No.

if (a || b || c) ...

means "if a is true or b is true or c is true".

And to clarify that, because the word "or" in English is horribly ambiguous, the expression "a || b" evaluates to true if one, or both, of a and b are true. (And therefore, to false if both of them are false.)
 
Raj Gurung
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK so in example given below, if(a || b || c) command gets executed only if one of a, b or c is equal to true; even if boolean a=false, boolean b=false and boolean c=false is before if(a || b || c) conditions???

boolean a=false;
boolean b=false;
boolean c=false;
if (a || b || c)
{
statements;
}



Thanks
 
Marshal
Posts: 79010
375
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried it?
Do some working out with a pencil and paper and see whether any of the combinations of p q and r with the [inclusive]OR operator evaluate to true. You may find the easiest way to do that is to draw a truth table.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic