Hide

Problem A
Logic Functions

In addition to the normal boolean operators we use (such as or, ||, and, && and negation, !) there are also a number of additional operators that might be of interest.

Task

In this problem, your task is to write C++ functions that implement a few of them. You will give the output not as a return value, but instead update variables that are passed into your functions as references.

The functions you are to implement are described using truth tables, i.e. an exhaustive list of what the output should be for each input:

The exclusive or

Also abbreviated xor, with the mathematical notation $x \mathbin {\oplus } y$.

$x$

$y$

$x \mathbin {\oplus } y$

$T$

$T$

$F$

$T$

$F$

$T$

$F$

$T$

$T$

$F$

$F$

$F$

The implication

Given the notation $x \rightarrow y$.

$x$

$y$

$x \rightarrow y$

$T$

$T$

$T$

$T$

$F$

$F$

$F$

$T$

$T$

$F$

$F$

$T$

The equivalence

Given the notation $x \leftrightarrow y$.

$x$

$y$

$x \leftrightarrow y$

$T$

$T$

$T$

$T$

$F$

$F$

$F$

$T$

$F$

$F$

$F$

$T$

Template

You can download the template logicfunctions.cpp from the Attachments menu to implement your functions. When submitting your solution, only send in this file.

Testing

First, download the file logicfunctions.h from the Attachments menu and save it in the same place as your solution. That file calls your program with a fixed test case and reports whether it was correct.

Please log in to submit a solution to this problem

Log in