// // Filename: pgm2_9a.cpp // // Description: Demonstration of logical OR and logical AND. // // ENSC 104: Digital Computer Programming // // Instructor: Dr. Walsh // // Section: 2 // // Date Created: 02/23/98 // Last Modified: 02/23/98 // // Name: N/A // #include int main( int argc, char *argv[] ) { int x; int y; cout << " X " << " Y " << " X&&Y " << " X||Y " << " !X " << " !Y " << " !X||!Y " << " !(X&&Y) " << endl; cout << "*****************************************\n"; for( x=0; x<=1; x++) { for( y=0; y<=1; y++) { cout << " " << x << " " << y << " " << (x&&y) << " " << (x||y) << " " << (!x) << " " << (!y) << " " << ( !x || !y) << " " << (!( x && y )) << endl; } } cout << "\n\nDEMORGAN'S LAW\n"; cout << "****************\n\n"; cout << " !(X&&Y) = !X || !Y\n\n"; cout << "and\n\n"; cout << " !(X||Y) = !X && !Y\n"; return 0; }