Skip to content

Instantly share code, notes, and snippets.

@perryh
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save perryh/9067056 to your computer and use it in GitHub Desktop.
Save perryh/9067056 to your computer and use it in GitHub Desktop.
#include <stdio.h>
/* Define constants */
int main()
{
/*********************/
/* Declare variables */
/*********************/
unsigned int a,b, Q1, Q2; /* counters for the input logic values */
/*************************************/
/* Compute and print the truth table */
/*************************************/
printf(" A B | Q1 Q2 \n"); /* print truth table header */
printf("-------|--------\n");
/* cycle through all input bit combinations */
for ( a = 0; a <= 1; a = a + 1 )
{
for ( b = 0; b <= 1; b = b + 1 )
{
{
Q1 = !(a & b) ; /* compute desired logical operation */
printf(" %u %u | %u %u \n", a, b, Q1, Q2);
}
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment