C++ program to perform the boolean operations
kw.cpp
#include <iostream>
using namespace std;
int main()
{
    int a = 0, b = 1;
    cout<<"———————————————————————————————————————————";
    cout<<"\nProgram to perform the boolean operations";
    cout<<"\n———————————————————————————————————————————";
    cout<<"\nValue of a     | "<<a;
    cout<<"\nValue of b     | "<<b;
    cout<<"\nValue of "<<a<<" | "<<b<<" | "<<(a | b);
    cout<<"\nValue of "<<a<<" & "<<b<<" | "<<(a & b);
    cout<<"\nValue of "<<a<<" ^ "<<b<<" | "<<(a ^ b);
    cout<<"\nValue of "<<a<<" ||"<<b<<" | "<<(a || b);
    cout<<"\nValue of "<<a<<" &&"<<b<<" | "<<(a && b);
    cout<<"\n———————————————————————————————————————————\n";
    return 0;
}
Output
kodingwindow@kw:~$ g++ kw.cpp
kodingwindow@kw:~$ ./a.out ——————————————————————————————————————————— Program to perform the boolean operations ——————————————————————————————————————————— Value of a | 0 Value of b | 1 Value of 0 | 1 | 1 Value of 0 & 1 | 0 Value of 0 ^ 1 | 1 Value of 0 ||1 | 1 Value of 0 &&1 | 0 ——————————————————————————————————————————— kodingwindow@kw:~$
Advertisement