I'm trying to create a truth table in c, I have the left side built so i was able to show all the possibilities of the input numbers in a truth table. but i am having trouble getting the right output for the right side of the truth table. What I mean is we ask the user to write 1 or 0 and once we got trough all the row it should print the user's input on the right side of the truth table.
For example:
row 0:1
row 1:0
row 2:0
row 3:0
row 4:1
row 5:1
row 6:0
row 7:0
Output should look like this
0, 0, 0, : 1
0, 0, 1, : 0
0, 1, 0, : 0
0, 1, 1, : 0
1, 0, 0, : 1
1, 0, 1, : 1
1, 1, 0, : 0
1, 1, 1, : 0
As you can see, the input from the user should be on the right side of truth table
#include <stdio.h>
void increment(int truth_table[8][4], int f[8]){
for(int z=0; z<=1; z++){
for(int y=0;y<=1; y++){
for(int x=0; x<=1; x++){
for(int j = 0; j < 1; j = j + 1){
printf("%d %d %d : %d\n", z,y,x,f[j]);
}
}
}
}
}
void right_side(int truth_table[8][4], int f[8]){
for(int i = 0; i < 8; i = i + 1) {
for(int j = 0; j < 1; j = j + 1) {
printf("row %d:",j);
scanf(" %d", &f[j]);
}
}
increment(truth_table,f);
}
int main(void) {
int f[8];
int truth_table[8][4] = {0};
right_side(truth_table,f);
return 0;
}