Ask Question
30 July, 22:59

Write the proghrams for the following:

1. Given values for two Boolean variables a and b, the expression evaluates to True if just one of a or b is True, but not if both are True or both or False i. (Note: this is also called an "exclusive or" between a and b.)

2. Given values for three Boolean variables a, b, and c, the expression evaluates to True if an odd number (i. e. exactly 1 or 3) of the variables a, b, and c is True, and is False otherwise. a. Note: Use only Boolean expressions. Do not use if-elif-else blocks

+4
Answers (1)
  1. 31 July, 02:43
    0
    a)

    #include

    using namespace std;

    int main () {

    bool a, b, c;

    cin>>a>>b;

    if (a^b) / /X-OR operator in C++.

    c=true;

    else

    c=false;

    cout<
    return 0;

    }

    b)

    #include

    using namespace std;

    int main () {

    bool a, b, c, d;

    cin>>a>>b>>c;

    if ((a^b) ^c) / /X-OR operator in C++.

    d=true;

    else

    d=false;

    cout<
    return 0;

    }

    Explanation:

    The above written programs are in C++. There is an operator (^) called X-OR operator in C++. It returns true if the number of 1's are odd and returns false if the number of 1's are even.

    In the if statement I have user X-OR operator (^) to find the result and storing the result in another boolean variable in both the questions.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write the proghrams for the following: 1. Given values for two Boolean variables a and b, the expression evaluates to True if just one of a ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers