Main Menu


Sponsored Links

  


  
  
Web Cartoon Maker: a Fun Way to Learn C++ Contents Previous Next

Logical (Boolean) Operators

There are three logical operators in C++: AND, OR and NOT, which are denoted by the symbols && , || and ! . The semantics (meaning) of these operators is similar to their meaning in English. For example dX > 0 && dX < 10 is true only if dX is greater than zero AND less than 10.

bEvenFlag || iN%3 == 0 is true if either of the conditions is true, that is, if bEvenFlag is true OR the number is divisible by 3.

Finally, the NOT operator has the effect of negating or inverting a bool expression, so !bEvenFlag is true if bEvenFlag is false; that is, if the number is odd.

Logical operators often provide a way to simplify nested conditional statements. For example, it is easy to write the following code:

if ( iX > 0 )

{

if ( iX < 10 )

{

ShowText ( "iX is a positive single digit" );

}

}

using a single conditional:

if ( iX > 0 && iX < 10 )

{

ShowText ( "iX is a positive single digit" );

}


Contents Previous Next
  
News

New Tales Animator Video by Alan Sturgess

Alan Sturgess shared an excellent video he made using Tales Animator! You can still download Tales Animator here. Unfortunately it is only available for Wi

...

Simple Online Character Designer

There is a prototype of simple online character designer available HERE. It is only a prototype, it does not contain many pieces yet but it can already generat

...

Book is updated

Now our book "Web Cartoon Maker: A Fun Way to Learn C++" is fully in synch with WCM 1.5! It is available for download and online reading HERE.

...

Web Cartoon Maker 1.5 is here!

Web Cartoon Maker 1.5 is finally here! You can download it HERE! Here is what was updated in version 1.5: Web Cartoon Maker Desktop Edition is now fully standal

...

read more news...


Poll