/* TruthValues.c (c) Kari Laitinen http://www.naturalprogramming.com 2013-11-21 File created. 2013-11-21 Last modification. Notes: Old C compilers do not know the stdbool.h file, and they do not accept variable declarations between action statements inside a function. */ #include #include /* Definitions for bool, true, and false */ int main() { bool true_boolean_variable = true ; bool false_boolean_variable = false ; printf( "\n In C, expressions are evaluated so that\n" "\n - a true expression has value %d" "\n - a false expression has value %d", ( 99 == 99 ), ( 99 == 88 ) ) ; printf( "\n\n Boolean variables can have values" "\n - %d means true " "\n - %d means false\n", true_boolean_variable, false_boolean_variable ) ; int left_integer = 4, right_integer ; printf( "\n left right < >= != \n" ) ; for ( right_integer = 0 ; right_integer < 7 ; right_integer ++ ) { printf( "\n %d %d", left_integer, right_integer ) ; bool first_truth_value = ( left_integer < right_integer ) ; bool second_truth_value = ( left_integer >= right_integer ) ; bool third_truth_value = ( left_integer != right_integer ) ; printf( " %d %d %d", first_truth_value, second_truth_value, third_truth_value ) ; } }