Functions

/Users/garethloy/Musimathics/Musimat1.2/MusimatTutorial/B0111.cpp File Reference

#include "MusimatTutorial.h"

Go to the source code of this file.

Functions

 MusimatTutorialSection (B0111)

Function Documentation

MusimatTutorialSection ( B0111   )

Definition at line 2 of file B0111.cpp.

                              {
        Print("*** B.1.11 Logical Operations ***");
        /*****************************************************************************
         
         B.1.11 Logical Operations
         
         Logical operators compare truth values. For example, the expression x And y is True if and only 
         if x == True and y == True. The expression x Or y is True if either x == True or 
         y == True.
         *****************************************************************************/
        
        Bool applesAreRed = True;
        Bool bananasAreYellow = True;
        Bool nightIsDay = False;

        Print("applesAreRed And bananasAreYellow is ", applesAreRed And bananasAreYellow); // prints 1
        Print("applesAreRed And nightIsDay is ", applesAreRed And nightIsDay); // prints 0
        
        Print("applesAreRed Or bananasAreYellow is ", applesAreRed Or bananasAreYellow); // prints 1
        Print("applesAreRed Or nightIsDay is ", applesAreRed Or nightIsDay); // prints 1

        /*****************************************************************************
         
         B.1.11 Logical Operations
         
         We can invert the sense of a Bool expression with the operator "!".
         *****************************************************************************/
        
        Print("!applesAreRed is ", !applesAreRed); // prints 0
        
        Print("applesAreRed Or !bananasAreYellow is ", applesAreRed Or !bananasAreYellow); // prints 1
        Print("!applesAreRed Or nightIsDay is ", applesAreRed Or !nightIsDay); // prints 1

        
}