How to use variables in Boolean expressions?

The sample program in the preceding section uses a Boolean expression (4 < 54) that’s fairly useless because it’s always true. Every time that you run the program, it just prints the message Slap him on the wrist and let him go.

For greater flexibility, Boolean expressions usually compare two variables or one variable to a fixed value, as in the following examples:


(MyIQ >= AnotherIQ)
(Taxes < 100000)

The value of the first Boolean expression (MyIQ < AnotherIQ) depends on the value of the two variables MyIQ and AnotherIQ. Run the following Liberty BASIC program to see how it follows a different set of instructions, depending on the value of the MyIQ and AnotherIQ variables:


PROMPT “What is your IQ”; MyIQ
PROMPT “What is the IQ of another person”; AnotherIQ
IF (MyIQ >= AnotherIQ) THEN
 PRINT “I’m smarter than you are.”
END IF
IF (MyIQ < AnotherIQ) THEN
 PRINT “You have a higher IQ to make up for your lack of
           common sense.”
END IF
END

If you run this program and type different values for MyIQ and AnotherIQ, the program behaves in two possible ways: printing on-screen either I’m smarter than you are. or You have a higher IQ to make up for your lack of common sense.

Remember By using variables in Boolean expressions, you give your program the flexibility it needs to handle different data.


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

3 Responses to “How to use variables in Boolean expressions?”

  1. Hello! Please e-mail me your contacts. I have a question webmaster@bravto.ru” rel=”nofollow”>……

    Thank you!!!…


  2. MedicamentSpot.com. Canadian Health&Care.Best quality drugs.No prescription online pharmacy.Special Internet Prices. High quality drugs. Buy pills online

    Buy:Propecia.Tramadol.Viagra.Maxaman.Levitra.VPXL.Cialis Professional.Cialis Soft Tabs.Viagra Soft Tabs.Viagra Super Force.Cialis.Super Active ED Pack.Cialis Super Active+.Viagra Super Active+.Soma.Viagra Professional.Zithromax….


  3. MedicamentSpot.com. Canadian Health&Care.Special Internet Prices.No prescription online pharmacy.Best quality drugs. Online Pharmacy. Buy drugs online

    Buy:Viagra Soft Tabs.Viagra Super Force.Viagra.Super Active ED Pack.Cialis Soft Tabs.Levitra.Soma.Cialis Super Active+.Zithromax.Viagra Professional.VPXL.Viagra Super Active+.Cialis Professional.Propecia.Cialis.Tramadol.Maxaman….

Leave a Reply



eXTReMe Tracker