write a computer program that produces the desired output from the given input. Input: Truth values for two statement letters A and BOutput: Corresponding truth values (appropriatelylabeled, of course) for                                          A Λ B, A ∨ B, A → B, A ↔ B, A′

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

write a computer program that produces the desired output from the given input.

Input: Truth values for two statement letters A and B
Output: Corresponding truth values (appropriately
labeled, of course) for
                                          A Λ B, AB, AB, AB, A

Expert Solution
Step 1

Objective: This program prints the truth table of certain logic gates.

Programming language: since no language is mentioned, C++ is used.

Step 2

Answer:

#include <iostream> 
#include <stdlib.h> 
using namespace std;
void printAND(int A[],int B[])
{
    int Z;
    printf("AND gate\n");
    printf("A |\t |B\tZ=A AND B");
    for(int i = 0; i <4;i++) { 
        //computing AND gate values
        Z = A[i] & B[i]; 
        printf("\n %d |\t %d|\t%d",A[i],B[i],Z); 
    } 
}

void printOR(int A[],int B[])
{
    int Z;
    printf("OR gate\n");
    printf("A |\t |B\t|Z=A OR B");
    for(int i = 0; i <4;i++) { 
        //computing AND gate values
        Z = A[i] | B[i]; 
        printf("\n %d |\t %d|\t%d",A[i],B[i],Z); 
    } 
}

void printNOT(int B[])
{
    int Z;
    printf("NOT gate\n");
    printf("B\t|Z=NOT B");
    for(int i = 0; i <2;i++) { 
        //computing NOT gate values
        Z = !B[i]; 
        printf("\n%d|\t%d",B[i],Z); 
    } 
}

void printIMPLY(int A[],int B[])
{
    int Z;
    printf("IMPLES THAT\n");
    printf("A |\t |B\t|Z=A -> B");
    for(int i = 0; i <4;i++) { 
        //computing IMPLIES THAT
        if(A[i]==1 && B[i]==0)
            Z = 0; 
        else
            Z = 1;
        printf("\n %d |\t %d|\t%d",A[i],B[i],Z); 
    } 
}

void printEQUI(int A[],int B[])
{
    int Z;
    printf("EQUIVALENCE\n");
    printf("A |\t |B\t|Z=A <-> B");
    for(int i = 0; i <4;i++) { 
        //computing IMPLIES THAT
        if(A[i]==B[i])
            Z = 1; 
        else
            Z = 0;
        printf("\n %d |\t %d|\t%d",A[i],B[i],Z); 
    } 
}
int main() 

    int A[5] = { 0, 0, 1, 1}; 
    int B[5] = { 0, 1, 0, 1}; 
    int Z; 
    printAND(A,B);
    cout<<"\n";
    printOR(A,B);
    cout<<"\n";
    printNOT(B);
    cout<<"\n";
    printIMPLY(A,B);
    cout<<"\n";
    printEQUI(A,B);

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Fundamentals of Boolean Algebra and Digital Logics
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education