Write a C++ program to perform logical operators (logic explained)

Here is the C++ program to perform logical operations. You all should have in mind how it works exactly. Here is the algorithm.
Steps
User side:
1: User asked to enter a value for variable 'a' (it should be 1 or 0)
2: User again asked to enter a value for variable 'b' (it should be 1 or 0)
3: User will get the reults for And, Or and Not operations on values.
Developer side
1: Declare variables that are going to be used in program.
2: Input the value for variable 'a' from user.
3: Input the value for variable 'b' from user.
4: Display result for AND operator by placing (a&&b) in the 'cout' statement.
5: Display result for OR operator by placing (a||b) in the 'cout' statement.
6: Display result for And operator by placing (!a) in the cout statement and then (!b) in the 'cout' statement.
7: Program end.

Code:

#include<iostream>



using namespace std;

int main()
{
      
       bool a, b;
       cout << "Enter The Value Of a (1 or 0) : ";
       cin >> a;
       cout << "Enter The Value Of b ()a or 0) : ";
       cin >> b;
      
       cout << "AND : " << (a&&b) << endl;
       cout << "OR  : " << (a||b) << endl;
       cout << "NOT For a : " << (!a) << endl;
       cout << "NOT For b : " << (!b) << endl;
      
      
       system("pause");
       return 0;
}


Output

Comments