Thread: Logic Gates - Multiplexer Help

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    12

    Exclamation Logic Gates - Multiplexer Help

    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

    Logic Gates - Multiplexer Help-mux2x1_ckt-gif

    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
    Last edited by alexmallaburn; 02-22-2012 at 12:25 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C program related to logic gates!
    By yellowmania in forum C Programming
    Replies: 4
    Last Post: 02-14-2012, 07:38 AM
  2. Are you the next Gates?
    By swgh in forum A Brief History of Cprogramming.com
    Replies: 37
    Last Post: 08-04-2008, 06:59 PM
  3. Bill Gates!
    By Sentral in forum A Brief History of Cprogramming.com
    Replies: 30
    Last Post: 06-21-2006, 12:22 AM
  4. a multiplexer/data selector question
    By axon in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 10-12-2003, 02:48 PM
  5. Logic Gates
    By JFK in forum C Programming
    Replies: 0
    Last Post: 10-21-2001, 05:56 AM

Tags for this Thread