HA9Fe

Truth tables in C
~~~~~~~~~~~~~~~~~

  #include <stdio.h>
  #include <stdlib.h>

  int ttline ( int, int, int, int );
  void truth4 ( int (*f)(int, int, int, int) );

  int ttline ( int x3, int x2, int x1, int x0) {
    return 0;
  }

  void truth4 ( int (*f)(int, int, int, int ) ) {
    int x3, x2, x1, x0;
    for ( x3 = 0 ; x3 <= 1 ; x3++ ) {
      for ( x2 = 0 ; x2 <= 1 ; x2++ ) {
        for ( x1 = 0 ; x1 <= 1 ; x1++ ) {
          for ( x0 = 0 ; x0 <= 1 ; x0++ )
            printf("%x  %d %d %d %d  %d\n",
                   x3*8+x2*4+x1*2+x0,
                   x3, x2, x1, x0,
                   (*f)(x3,x2,x1,x0));
        }
      }
    }
  }

  int main() {
      truth4( ttline);
      return 0;
  }

Links:

  1. https://stackoverflow.com/questions/9410
           /how-do-you-pass-a-function-as-a-parameter-in-c

  2. http://math.hws.edu/bridgeman/courses/331
          /f05/handouts/c-c++-notes.html

