CSCD-255
2015-01-20


Expressions, Including Logical / Boolean (Chapter 12)

An arithmetic expression example:  solving the quadratic equation and the importance of parentheses:
quadratic.txt   quadratic.c   quadratic.exe

FULL table of operators and precedence — expanded beyond our book's Table 9.1:
Precedence.pdf

Program to generate truth tables for some boolean expressions.  [This uses elements of C that we have not yet covered.]
TruthTables.txt   TruthTables.c   TruthTables.exe

Trace control.  NOTE:  indentation can lie.
if(b > 0 || a > 0) { if (x > 0) printf ("one\n"); else // for if (x>0) printf ("two\n"); if(y < 5) printf ("forty-two\n"); }// end if(b>0||a>0) else // for if(b>0||a>0) { if (x < 0) printf ("three\n"); if (y < 0) printf ("four\n"); else // if (y < 0) printf ("five\n"); printf (“six\n"); }// end if/else on (b>0||a>0)
Within a program: NestedIf.txt   NestedIf.c   NestedIf.exe