I am completely new to C++ but have a background in VB, VBA, VBScript, VB.net.
Environment: Windows 10 Professional 64 bit.
Visual Studio Community 2019 V16.8.2
I am working on an Exercise in Sam's teach yourself C++ in One Hour a Day and have reviewed the answer but still cannot identify the problem.
Can someone please explain what I am doing wrong?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
// Chapter Five Exercise 3.cpp :
// Write a program that asks the user to input two boolean values and demonstrates the result of various bitwise operators on them.
//
#include <iostream>
using namespace std;
int main()
{
// initalize variables
bool bool1 = false;
bool bool2 = false;
//Gather input from user
cout << "Please enter two boolean values ( 1 for true, 0 for false)";
cin >> bool1;
cin >> bool2;
// display the results to the user in the console window
cout << "The various results of bitwise operations are:" << endl;
cout << "Bool1 NOT bool2 = " + (bool1 - bool2) << endl;
cout << "Bool1 AND bool2 = " + (bool1 & bool2) << endl;
cout << "Bool1 OR bool2 = " + (bool1 | bool2) << endl;
cout << "Bool1 XOR bool2 = " + (bool1 ^ bool2) << endl;
return 0;
}
|
current output:
Please enter two boolean values (1 for true, 0 for false)
1
1
The various results of bitwise operations are:
Bool1 NOT bool2 =
ool1 AND bool2 =
ool1 OR bool2 =
Bool1 XOR bool2 =
C:\Users\[user]\source\repos\Chapter Five Exercise 3\Debug\Chapter Five Exercise 3.exe (process 24140) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .