Right Complementation
When given a Truth Table, you see two columns of two different values that are related to each other and show opposite relationships, most of the time they are represented by F for false and T for true. Right Complementation is the opposite of the second column, or the right one. When representing each of the results for a 4 by 2 table, there are 16 possible results, one of them being the right complementation, which is actually represented by negation q.
equivalence/if and only if
The opposite of an XOR, if something is T and T, then it would be T when applied.
Demonstration of the indicated keyword.
The following is the code used to demonstrate if and only if/equivalence and the resulting output when the program is run:
1 #include <stdio.h> 2 3 char logicor( char, char ); 4 5 char logiciff( char a, char b ) 6 { 7 char x; 8 if(a == b) 9 x = 1; 10 else 11 x = 0; 12 return(x); 13 } 14 15 int main() 16 { 17 char p = 1; 18 char q = 1; 19 20 // Printing the OR Truth Table 21 22 printf("\nTreat 0 as false, and 1 as true.\n\tXOR Truth Table:\n\n"); 23 printf("\t P | Q | X \n"); 24 printf("\t___________\n"); 25 26 // Printing the first set of values (values for p, q, and the result of p|q) 27 28 printf("\t %d | %d | %d \n", p, q, logiciff( p, q )); 29 q = 0; 30 printf("\t %d | %d | %d \n", p, q, logiciff( p, q )); 31 p = 0; 32 q = 1; 33 printf("\t %d | %d | %d \n", p, q, logiciff( p, q )); 34 q = 0; 35 printf("\t %d | %d | %d \n\n", p, q, logiciff( p, q )); 36 37 // Printing PART 3 38 39 /* printf("\tOR Truth Table comparing X and Q:\n\n"); 40 printf("\t P | Q | X | ( X|Q )\n"); 41 printf("\t____________________\n"); 42 43 p = 1; 44 q = 1; 45 46 printf("\t %d | %d | %d | %d \n", p, q, logicor( p, q ), logicor( logicor( p, q ), q )); 47 q = 0; 48 printf("\t %d | %d | %d | %d \n", p, q, logicor( p, q ), logicor( logicor( p, q ), q )); 49 p = 0; 50 q = 1; 51 printf("\t %d | %d | %d | %d \n", p, q, logicor( p, q ), logicor( logicor( p, q ), q )); 52 q = 0; 53 printf("\t %d | %d | %d | %d \n", p, q, logicor( p, q ), logicor( logicor( p, q ), q ));*/ 54 return(0); 55 }
Alternatively (or additionally), if you want to demonstrate something on the command-line, you can do so as follows:
lab46:~/src/opus/opus1$ ./iff Treat 0 as false, and 1 as true. XOR Truth Table: P | Q | X ___________ 1 | 1 | 1 1 | 0 | 0 0 | 1 | 0 0 | 0 | 1 lab46:~/src/opus/opus1$