music
OSdata.com: programming text book 

OSdata.com

relation expressions

summary

    This subchapter looks at relation expressions.

free computer programming text book project

table of contents
If you like the idea of this project,
then please donate some money.
more information on donating

Google

stub section

    This subchapter is a stub section. It will be filled in with instructional material later. For now it serves the purpose of a place holder for the order of instruction.

    Professors are invited to give feedback on both the proposed contents and the propsed order of this text book. Send commentary to Milo, PO Box 1361, Tustin, California, 92781, USA.

relation expressions

    This subchapter looks at relation expressions.

    When we use a decision control structure, we are making a decision based on something. This something is whether or not something is true (or false).

    This something being tested for our decision is some kind of relation expression.

    The most basic is a simple test of truth. “Is this true?”

    With numbers, we can have a simple test of whether two numbers are equal or not equal. If the two numbers are not equal, we can test to see which is larger or which is smaller. And we can combine these two tests with (greater than or equal) or (less than or equal) -- parenthesis added for clarity.

    We can also use functions for simple testing. The function does some kind of evaluation and returns a result of either TRUE or FLASE and we use that result for our decision.

Stanford C essentials

    Stanford CS Education Library This [the following section until marked as end of Stanford University items] is document #101, Essential C, in the Stanford CS Education Library. This and other educational materials are available for free at http://cslibrary.stanford.edu/. This article is free to be used, reproduced, excerpted, retransmitted, or sold so long as this notice is clearly reproduced at its beginning. Copyright 1996-2003, Nick Parlante, nick.parlante@cs.stanford.edu.

Relational Operators

    These operate on integer or floating point values and return a 0 or 1 boolean value.

==      Equal
!=      Not Equal
>      Greater Than
<      Less Than
>=      Greater or Equal
<=      Less or Equal

    To see if x equals three, write something like:

    if (x == 3) …

    C does not have a distinct boolean type-- int is used instead. The language treats integer 0 as false and all non-zero values as true.

Pitfall ===

    An absolutely classic pitfall is to write assignment (=) when you mean comparison (==). This would not be such a problem, except the incorrect assignment version compiles fine because the compiler assumes you mean to use the value returned by the assignment. This is rarely what you want

    if (x = 3) …

    This does not test if x is 3. This sets x to the value 3, and then returns the 3 to the if for testing. 3 is not 0, so it counts as “true” every time. This is probably the single most common error made by beginning C programmers. The problem is that the compiler is no help -- it thinks both forms are fine, so the only defense is extreme vigilance when coding. Or write “= ≠ ==” in big letters on the back of your hand before coding. This mistake is an absolute classic and it’s a bear to debug. Watch Out! And need I say: “Professional Programmer’s Language.”

    Stanford CS Education Library This [the above section] is document #101, Essential C, in the Stanford CS Education Library. This and other educational materials are available for free at http://cslibrary.stanford.edu/. This article is free to be used, reproduced, excerpted, retransmitted, or sold so long as this notice is clearly reproduced at its beginning. Copyright 1996-2003, Nick Parlante, nick.parlante@cs.stanford.edu.

end of Stanford C essentials

JOVIAL

    The following material is from the unclassified Computer Programming Manual for the JOVIAL (J73) Language, RADC-TR-81-143, Final Technical Report of June 1981.

    The JOVIAL operators are summarized in the following table:

         Type          Operators       Operation

         Relational    <   >   =       less than, greater than, equal
                       <=  >=  <>      less than or equal,
                                          greater or equal, not equal

    A relational operator compares any two values of the same type
    and produces a Boolean value as its result.  A logical operator
    takes bit-string values and also produces a Boolean result.  (A
    Boolean value is a one-bit bit-string, representing "true" or
    "false", depending on whether it is one or zero.)

    The JOVIAL operators are described in detail in Chapter 11,
    where, for example, you will find the rules for operations on
    fixed values and for the comparison of such objects as
    character-strings and pointers.

    Chapter 1 Introduction, page 8


free music player coding example

    Coding example: I am making heavily documented and explained open source code for a method to play music for free — almost any song, no subscription fees, no download costs, no advertisements, all completely legal. This is done by building a front-end to YouTube (which checks the copyright permissions for you).

    View music player in action: www.musicinpublic.com/.

    Create your own copy from the original source code/ (presented for learning programming).


return to table of contents
free downloadable college text book

view text book
HTML file

Because I no longer have the computer and software to make PDFs, the book is available as an HTML file, which you can convert into a PDF.

previous page next page
previous page next page

free computer programming text book project

Building a free downloadable text book on computer programming for university, college, community college, and high school classes in computer programming.

If you like the idea of this project,
then please donate some money.

send donations to:
Milo
PO Box 1361
Tustin, California 92781

    At the time I write this message I am a few days from becoming homeless. That will greatly interfere with my ability to create this project, which can help nearly 20 million U.S. college students and more than 150 million students world-wide. I am looking for 30 rich people or corporations willing to donate $10 a month to my church so that the church can provide a place indoors for me to continue work. If you want to donate, please see help project. Thanks much.

Supporting the entire project:

    If you have a business or organization that can support the entire cost of this project, please contact Pr Ntr Kmt (my church)

more information on donating

Some or all of the material on this web page appears in the
free downloadable college text book on computer programming.


Google


Made with Macintosh

    This web site handcrafted on Macintosh computers using Tom Bender’s Tex-Edit Plus and served using FreeBSD .

Viewable With Any Browser


    †UNIX used as a generic term unless specifically used as a trademark (such as in the phrase “UNIX certified”). UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Ltd.

    Names and logos of various OSs are trademarks of their respective owners.

    Copyright © 2010, 2012 Milo

    Created: December 15, 2010

    Last Updated: October 16, 2012


return to table of contents
free downloadable college text book

previous page next page
previous page next page