- May 7, 2013
- 10,400
Code:
#include <iostream>
#include <cmath>
int main() {
bool p, q;
p = q = true;
std::cout << p << " XOR " << q << " is " <<
((p || q) && !(p && q)) << '\n';
p = false;
q = true;
std::cout << p << " XOR " << q << " is " <<
((p || q) && !(p && q)) << "\n";
p = true;
q = false;
std::cout << p << " XOR " << q << " is " <<
((p || q) && !(p && q)) << "\n";
p = q = false;
std::cout << p << " XOR " << q << " is " <<
((p || q) && !(p && q)) << "\n";
std::cin.get();
return 0;
}
Okay, since I've decided to learn C++ again, I came across this example of testing the truth table and the XOR expression. I'm confused to why the author has added the <cmath> header, which is used for maths functions and doesn't seem to have any relevance in the program.
Any ideas?