/* Print a table of values for some boolean functions. */ #include char bool (int i); int main(void) { int b1, b2, b3, b4; /* boolean variables */ int cnt = 0; /*headings*/ printf("\n%5s%5s%5s%5s%5s%7s%7s\n\n", "Cnt", "b1", "b2", "b3", "b4", "fct1", "fct2"); for (b1 = 0; b1 <= 1; ++b1) for (b2 = 0; b2 <= 1; ++b2) for (b3 = 0; b3 <= 1; ++b3) for (b4 = 0; b4 <= 1; ++b4) printf("%5d%5c%5c%5c%5c%7c%7c\n", ++cnt, bool(b1), bool(b2), bool(b3), bool(b4), bool(b1 || b2 || b3 || b4), bool(!(!b1 || b2) && (!b3 || b4)) ); printf("\n"); return 0; } char bool (int i){ if (i==0) return 'F'; else return 'T'; }