Hi, I have to make a 2:1 multiplexer in C programming for an assignment
The user has to input A B & C (with C being the switcher)
Y is the output
Truth table
C |
A |
B |
Y |
0 |
0 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
1 |
0 |
1 |
0 |
1 |
1 |
1 |
1 |
0 |
0 |
0 |
1 |
0 |
1 |
1 |
1 |
1 |
0 |
0 |
1 |
1 |
1 |
1 |
**Updated the truth table, since I ..........ed up the first one
Like the image above but, S = C
We have to make it out of standard gates, (AND, OR, NOT etc)
I have done this so far, it has no errors (but doesn't return the correct numbers - BIG ERROR)
Code:
#include<stdio.h>int And1(int a, int b);
int And2(int b, int c);
int Not(int c);
int Or (int And1, int And2);
int main (void)
{
int a;
int b;
int c;
printf("\nEnter Value for A: ");
scanf("%i", &a);
printf("\nEnter Value for B: ");
scanf("%i", &b);
printf("\nEnter Value for C: ");
scanf("%i", &c);
printf("\n\nValue from Multiplexer = %d", Or);
system("PAUSE");
return 0;
}
int Not(int c)
{
int output;
if(c==0)
output=1;
else
output=0;
return (output);
}
int And1(int a, int Not)
{
int output;
if(a==1 && Not==1)
output=1;
else
output=0;
return (output);
}
int And2(int b, int c)
{
int output;
if (b==0 && c==0)
output=0;
if (b==0 && c==1)
output=0;
if(b==1 && c==0)
output=0;
if(b==1 && c==1)
output=1;
return (output);
}
int Or(int And1, int And2)
{
int output;
if(And1==0 && And2==0)
output=0;
if(And1==1 && And2==0)
output=1;
if(And1==0 && And2==1)
output=1;
if(And1==1 && And2==1)
output=1;
return (output);
}
Any help would be much appreciated, I have looked on numerous forums and can find nothing that matches this