Created
November 9, 2021 09:21
-
-
Save suryansh011/67fc1e7d64b48867b3b165250120585e to your computer and use it in GitHub Desktop.
Program 6 (CDNI Truth Table)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
char TorF(int i) { | |
if (i == 1) | |
return 'T'; | |
else | |
return 'F'; | |
} | |
int main() { | |
int a[2][2], b[2][2], c[2], d[2][2]; | |
int i, j; | |
for(i = 0; i <= 1; i++) { | |
for(j = 0; j <= 1; j++) { | |
a[i][j] = ( i&&j ); | |
b[i][j] = (i || j); | |
d[i][j] = (!i || j); | |
} | |
} | |
for(i=0;i<=1;i++) { | |
c[i] = ( !i ); | |
} | |
printf("\nThe Truth Table for Conjunction: \n"); | |
printf(" A B : C\n"); | |
for(i=0; i<=1; i++) { | |
for(j=0; j<=1; j++) { | |
printf(" %c %c : %c\n", TorF(i), TorF(j), TorF(a[i][j])); | |
} | |
} | |
printf("\nThe Truth Table for Disjunction: \n"); | |
printf(" A B : C\n"); | |
for(i = 0; i <= 1; i++) { | |
for(j = 0; j <= 1; j++) { | |
printf(" %c %c : %c\n", TorF(i), TorF(j), TorF(b[i][j])); | |
} | |
} | |
printf("\nThe Truth Table for Negation: \n"); | |
printf(" A : C\n"); | |
for(i = 0; i <= 1; i++) { | |
printf(" %c : %c\n", TorF(i), TorF(c[i])); | |
} | |
printf("\nThe Truth Table for Implication: \n"); | |
printf(" A B : C\n"); | |
for(i = 0; i <= 1; i++) { | |
for(j = 0;j <= 1; j++) { | |
printf(" %c %c : %c\n", TorF(i), TorF(j), TorF(d[i][j])); | |
} | |
} | |
printf("\nNAME\nROLL\nSECTION"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment