#include
#include
using namespace std;
/*
* This C++ program prompts the user to enter two integer
* numbers (i.e. it is an interactive program). The program
* uses these numbers as operand values to the logical operators.
*
* @creator gdt
* @created 02001.10.01
* @version 02007.09.15
*/
int main(int, char**) {
int a, b;
cerr << "Enter two integers: ";
cin >> a >> b;
cout << "Numbers entered: " << a << " and " << b << endl;
int result = a && b;
cout << a << " && " << b << " is " << result << endl;
result = a || b;
cout << a << " || " << b << " is " << result << endl;
result = !a;
cout << '!' << a << " is " << result << endl;
cout << '!' << b << " is " << !b << endl;
//unary not ! has higher precedence than does <<
int c = a - b;
cout << a << " && " << b << " && " << c << " is "
<< (a && b && c) << endl;
//the insertion operator << has higher precedence than
//does the logical and operator &&... ()'s are required
//around the logical and EXPR...
return EXIT_SUCCESS;
}
/***
Numbers entered: 0 and 0
0 && 0 is 0
0 || 0 is 0
!0 is 1
!0 is 1
0 && 0 && 0 is 0
Numbers entered: 1 and 0
1 && 0 is 0
1 || 0 is 1
!1 is 0
!0 is 1
1 && 0 && 1 is 0
Numbers entered: 0 and 1
0 && 1 is 0
0 || 1 is 1
!0 is 1
!1 is 0
0 && 1 && -1 is 0
Numbers entered: 1 and 1
1 && 1 is 1
1 || 1 is 1
!1 is 0
!1 is 0
1 && 1 && 0 is 0
***/