Question

In: Computer Science

Write in C++ and insert comments. Input two values a and b 0 may be used...

Write in C++ and insert comments.

Input two values a and b

0 may be used for False

1 may be used for True

Write a program that will print the truth table for the logical operator and give the results for the specific input a, b. The following logical operators should be coded.

● conjunction (AND)

● disjunction (OR)

● conditional Statement (If a then b)

● exclusive OR (XOR)

● biconditional operation (p iff q)

Example for conjunction If the specific input is a=0, b=1, the output for a conjunction should look something like

Truth Table

For a logical conjunction

0 0 0

0 1 0

1 0 0

1 1 1

For the specific values a=1, b=1 the conjunction is true.

(Provide two output one for a,b true and one for a,b false)

Solutions

Expert Solution

#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
        int a,b,temp,i;
        cout<<"\tA B Conj Disj Xor \tBicon \t\t Cond"<<endl;
        for(i=0;i<4;i++){
                temp=i;
                a=i%2;
                temp/=2;
                b=temp%2;
                int c=a&&b;
                int d=a||b;
                int e=a^b;
                cout<<endl<<"\t"<<b<<" "<<a<<" "<<c<<" "<<d<<" "<<e;
                if(a==b){
                        cout<<"\t\t"<<"2";
                }
                else
                        cout<<"\t\t"<<"1";
                if(a==b){
                        cout<<"\t\t"<<"2";
                }
                else{
                        if(a==1 && b==0){
                                cout<<"\t\t"<<"1";
                        }
                        else{
                                cout<<"\t\t"<<"2";
                        }
                }
        }
        
}

Related Solutions

Write the C code required to configure pin 0 on port B to be an input...
Write the C code required to configure pin 0 on port B to be an input with the pullup resistor enabled.
• Write a C++ program that asks the user to input two integer values, then calls...
• Write a C++ program that asks the user to input two integer values, then calls a void function "swap" to swap the values for the first and second variable. • As we mentioned before, in order to swap the valors of two variables, one can use the following: temp= variable1; variable1 = variable2; variable2 = temp; • Display the two variables before you call swap and after you call that function. Comment in code would be greatly appreciated to...
Write a program in Java that will take as input two sets A and B, and...
Write a program in Java that will take as input two sets A and B, and returns a list of all functions from A to B.
Write short notes on the following (a) Floating input   (b) setpoint    (c) CMRR
Write short notes on the following (a) Floating input   (b) setpoint    (c) CMRR
Suppose that the double variables a, b and c contain the values -10, 0 1 and2...
Suppose that the double variables a, b and c contain the values -10, 0 1 and2 1 respectively, and the boolean variables b1, b2 and b3 contain the values true, false and false respectively Is each of the following expressions legal or illegal and what will the result be? a) a> b || b>c b) b1 | | b2 && b3
write C program to implement the priority queue with the operation insert
write C program to implement the priority queue with the operation insert
Discuss the influence of: (a) the two mean values; (b) the two standard deviations; and (c)...
Discuss the influence of: (a) the two mean values; (b) the two standard deviations; and (c) the number of data points for each data set in the statistical analysis that seeks to determine if two mean values from two different populations are statistically equivalent (or not). Assume the same level of significance (p = 0.05) for your discussion.
Lab 1 Write a program in the C/C++ programming language to input and add two fractions...
Lab 1 Write a program in the C/C++ programming language to input and add two fractions each represented as a numerator and denominator. Do not use classes or structures. Print your result (which is also represented as a numerator/denominator) to standard out. If you get done early, try to simplify your result with the least common denominator. The following equation can be used to add fractions: a/b + c/d = (a*d + b*c)/(b*d) Example: 1/2 + 1/4 = ( 1(4)...
Write a program that takes three sets ’A’, ’B’, ’C’ as input read from the file...
Write a program that takes three sets ’A’, ’B’, ’C’ as input read from the file prog2 input.txt. The first line of the file corresponds to the set ’A’, the second line is the set ’B’, and the third line is the set ’C’. Every element of each set is a character, and the characters are separated by space. Implement algorithms for the following operations on the sets. Each of these algorithms must be in separate methods or subroutines. The...
Write a program that takes two sets ’A’ and ’B’ as input read from the file...
Write a program that takes two sets ’A’ and ’B’ as input read from the file prog1 input.txt. The first line of the file corresponds to the set ’A’ and the second line is the set ’B’. Every element of each set is a character, and the characters are separated by space. Implement algorithms for the following operations on the sets. Each of these algorithms must be in separate methods or subroutines. The output should be written in the file...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT