• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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
 
Sheriff
Posts: 28348
97
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: 80140
418
  • 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.
 
No matter. Try again. Fail again. Fail better. This time, do it with this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic